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