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