#include <bits/stdc++.h>
using namespace std;
long long q[2000010];
long long pp, k, pre, cnt;
inline long long in() {
  long long x = 0, ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    ;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x;
}
int main() {
  pp = in();
  k = in();
  pre = pp;
  do {
    if (q[cnt] % k == 0)
      q[++cnt] = -pp / k;
    else {
      if (pp > 0)
        q[++cnt] = -pp / k;
      else
        q[++cnt] = -pp / k + 1;
    }
    pp = q[cnt];
  } while (pp);
  printf("%I64d\n", cnt);
  printf("%I64d", k * q[1] + pre);
  for (int i = 2; i <= cnt; i++) printf(" %I64d", q[i] * k + q[i - 1]);
  return 0;
}
