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