#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  long long x, y, c = 0, z = 1;
  bool ok = false;
  cin >> x >> y;
  z = x;
  if (x == y) {
    cout << "YES" << endl;
    cout << "0" << endl;
  } else {
    for (int i = 0; i < 10000; i++) {
      z *= x;
      c++;
      if (z == y) {
        cout << "YES" << endl;
        cout << c << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }
  return 0;
}
