#include <bits/stdc++.h>
using i64 = int64_t;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int main() {
i64 s, x;
std::cin >> s >> x;
if (std::gcd(s, x) == 1) {
std::cout << "1\n";
std::cout << s << '\n';
return 0;
}
std::uniform_int_distribution<int> dist(0, x - 1);
bool flag = false;
auto get = [&](i64 s) {
int T = 1e7;
while (T--) {
i64 a = dist(rng), b = s - a;
if (llabs(std::gcd(a, x)) == 1 && llabs(std::gcd(b, x)) == 1) {
flag = true;
return std::make_pair(a, b);
}
}
return std::make_pair(0LL, 0LL);
};
auto [a, b] = get(s);
if (flag) {
std::cout << "2\n";
std::cout << a << ' ' << b << '\n';
return 0;
}
auto [p, q] = get(s + 1);
assert(flag);
std::cout << "3\n";
std::cout << "-1 " << p << ' ' << q << '\n';
}