#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, t, z, sum = 0, mx = 0, l, x;
  cin >> n >> m;
  x = n;
  if (m % n != 0) {
    cout << "NO";
  } else {
    while (m % n == 0) {
      m /= n;
      mx++;
    }
    if (m != 1)
      cout << "NO";
    else
      cout << "YES\n" << mx - 1;
  }
}
