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