#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
void file() {}
int main() {
  fast();
  long long n, m, x;
  cin >> n >> m;
  x = n;
  for (long long i = 0; n <= m; i++, n *= x) {
    if (n == m) {
      cout << "YES\n";
      cout << i;
      return 0;
    }
  }
  cout << "NO";
}
