#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e3 + 113;
long long n, k, cnt = 0;
int main() {
  cin >> k >> n;
  while (n > k) {
    if (n % k != 0) {
      cout << "NO";
      return 0;
    }
    n /= k;
    cnt++;
  }
  if (n == k) {
    cout << "YES" << endl << cnt;
    return 0;
  }
  cout << "NO";
}
