#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k;
  while (cin >> k) {
    long long l;
    cin >> l;
    long long po = 1;
    bool found = false;
    int cnt = 0;
    while (po <= 10000000000LL) {
      cnt++;
      po *= k;
      if (po == l) {
        found = true;
        break;
      }
    }
    if (found) {
      cout << "YES" << endl;
      cout << cnt - 1 << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
