#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> k;
  cin >> n;
  long long sum = 0;
  while (n > k && n % k == 0) {
    sum++;
    n /= k;
  }
  if (n != k)
    cout << "NO"
         << "\n";
  else
    cout << "YES"
         << "\n"
         << sum << "\n";
  return 0;
}
