#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ans = 0;
  cin >> a >> b;
  while (b > 1) {
    if (b % a == 0) {
      b /= a;
      ans++;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl << ans - 1 << endl;
  return 0;
}
