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