#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, l;
  cin >> k >> l;
  int cnt = 0;
  long long res = k;
  while (res != l) {
    if (res >= l) break;
    cnt++;
    res *= k;
  }
  if (res == l) {
    cout << "YES" << endl;
    cout << cnt << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
