#include <bits/stdc++.h>
using namespace std;
int main() {
  int factor;
  int power;
  int to_power = -1;
  cin >> factor;
  cin >> power;
  while (power % factor == 0) {
    power /= factor;
    to_power++;
  }
  if (to_power >= 0 && power == 1)
    cout << "YES" << endl << to_power << endl;
  else
    cout << "NO" << endl;
}
