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