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