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