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