#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  int count = 0;
  while (k % n == 0) {
    k = k / n;
    count++;
  }
  if (k == 1)
    cout << "YES" << endl << count - 1;
  else
    cout << "NO";
  return 0;
}
