#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, l, m = 0, k;
  cin >> n >> l;
  k = n;
  while (k <= l) {
    if (k == l) {
      cout << "YES" << endl << m << endl;
      return 0;
    }
    k *= n;
    m++;
  }
  cout << "NO" << endl;
  return 0;
}
