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