#include <bits/stdc++.h>
using namespace std;
long long modRecursion(long long a, long long b);
int main() {
  long long cnt = 0;
  long long s, n, r, k, t;
  cin >> k >> n;
  long long c = 0;
  for (long long i = k; i <= n; i *= k) {
    c++;
    if (n == i) {
      cout << "YES"
           << "\n"
           << c - 1;
      return 0;
    }
  }
  cout << "NO";
}
