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