#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, l;
  cin >> k >> l;
  int i = 0;
  while (l % k == 0 && k != l) {
    l = l / k;
    i += 1;
  };
  if (k == l) {
    cout << "YES" << endl << i;
  } else {
    cout << "NO";
  };
  return 0;
}
