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