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