#include <bits/stdc++.h>
using namespace std;
vector<long long> vec;
long long ans[5003];
int main() {
  long long p, k;
  scanf("%lld %lld", &p, &k);
  if (p < k) {
    printf("1\n");
    printf("%lld\n", p);
    return 0;
  }
  long long llimitc =
      ceil((long double)(-1.0 * (long double)p) / (long double)k);
  vec.push_back(llimitc);
  int cnt = 0;
  while (true) {
    long long cur = vec[vec.size() - 1];
    if (cur >= 1 && cur < k) {
      break;
    }
    long long hlp =
        ceil((long double)(-1.0 * (long double)cur) / (long double)k);
    vec.push_back(hlp);
    cnt++;
    if (cnt > 70) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 0; i < vec.size(); i++) {
    ans[i + 1] += vec[i];
    ans[i] += (k * vec[i]);
  }
  ans[0] += p;
  printf("%d\n", (int)vec.size() + 1);
  for (int i = 0; i <= vec.size(); i++) {
    printf("%lld ", ans[i]);
  }
}
