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