#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b;
  cin >> a >> b;
  if (b % a != 0)
    cout << "NO";
  else {
    ll cnt = 0;
    ll temp = a;
    while (temp < b) {
      cnt++;
      temp *= a;
    }
    if (temp == b) {
      cout << "YES"
           << "\n";
      cout << cnt;
    } else
      cout << "NO";
  }
  return 0;
}
