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