#include <bits/stdc++.h>
using namespace std;
int main() {
  long double base, res, powe = 0;
  cin >> base >> res;
  for (int i = 0; i <= 31; i++)
    if ((pow(base, i)) == res) {
      cout << "YES" << endl;
      cout << i - 1 << endl;
      return 0;
    }
  cout << "NO" << endl;
  return 0;
}
