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