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