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