#include <bits/stdc++.h>
const int MAX = 2000111;
using namespace std;
void get(long long n, long long s) {
  set<long long> v;
  long long temp = n - s;
  if (temp < 0) {
    cout << -1;
    return;
  } else if (temp == 0) {
    cout << n + 1;
    return;
  }
  v.insert(temp);
  if (temp % 2 == 0) v.insert(2);
  for (long long i = 3; i * i <= temp; i += 2) {
    if (temp % i == 0) v.insert(i), v.insert(n / i);
  }
  for (auto i : v) {
    cout << i << " ";
    if (i > 1LL * sqrt(n)) {
      cout << i + 1;
      return;
    }
  }
  cout << -1;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, s;
  cin >> n >> s;
  for (long long i = 2; i * i <= n; i++) {
    long long nn = n, ans = 0;
    while (nn > 0) {
      ans += nn % i;
      nn /= i;
    }
    if (ans == s) {
      cout << i;
      return 0;
    }
  }
  if (s >= 0) {
    get(n, s);
  } else
    cout << -1;
  return 0;
}
