#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, k, tot = 1, cnt = 0;
  cin >> n >> k;
  while (tot < k) {
    tot = tot * n;
    cnt++;
  }
  if (tot == k) {
    cout << "YES" << endl;
    cout << cnt - 1 << endl;
  } else
    cout << "NO" << endl;
}
int main() {
  ios::sync_with_stdio(0);
  solve();
}
