#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, l, i = 0;
  cin >> k >> l;
  while (pow(k, i) != l) {
    i++;
    if (pow(k, i) > l) {
      i = -1;
      break;
    }
  }
  if (i == -1)
    cout << "NO";
  else
    cout << "YES" << endl << i - 1;
}
