#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, c;
  cin >> k >> c;
  long long f = k;
  if (k == c) {
    cout << "YES\n0\n";
    return 0;
  }
  for (int i = 1; k < c; i++) {
    k *= f;
    if (k == c) {
      cout << "YES\n";
      cout << i << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
