#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, l, x;
  cin >> k >> l;
  x = k;
  for (int i = 0;; i++) {
    if (x == l) {
      cout << "YES" << endl;
      cout << i;
      break;
    }
    if (x > l) {
      cout << "NO";
      break;
    }
    x = x * k;
  }
}
