#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  while (m % n == 0 && m != 1) {
    m = m / n;
    ans++;
  };
  if (m == 1) {
    cout << "YES\n";
    cout << ans - 1;
  } else
    cout << "NO\n";
  return 0;
}
