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