#include <bits/stdc++.h>
using namespace std;
int k, l;
int times = 0;
void start() {
  cin >> k >> l;
  if (l % k != 0) {
    cout << "NO" << '\n';
    return;
  }
  while (l != 1) {
    if (l % k != 0) {
      cout << "NO" << '\n';
      return;
    }
    l /= k;
    times++;
  }
  cout << "YES" << '\n';
  cout << times - 1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  start();
  return 0;
}
