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