#include <bits/stdc++.h>
const int MAXINT = 2147483640;
const long long MAXLL = 9223372036854775800LL;
const long long MAXN = 1123456;
const long long MOD = 1123456769;
using namespace std;
long long ans[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(time(0));
  long long p, k, i, x, res;
  cin >> p >> k;
  for (i = 0; i <= 100000; i++) {
    x = -p / k;
    if (x * k + p < 0) ++x;
    ans[i] = x * k + p;
    if (x >= 0 && x < k) {
      res = i + 2;
      if (!x)
        --res;
      else
        ans[res - 1] = x;
      cout << res << "\n";
      for (int j = 0; j < res; j++) cout << ans[j] << " ";
      return 0;
    }
    p = x;
  }
  cout << -1 << "\n";
  return 0;
}
