#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
double power(double x, int n) {
  if (n == 0) return 1;
  if (n < 0) return 1 / x * power(1 / x, -(n + 1));
  double half = power(x, n / 2);
  return n % 2 ? x * half * half : half * half;
}
int main() {
  int n, m;
  cin >> n >> m;
  string ans = "NO";
  int c;
  for (int i = 1; power(n, i) <= m; i++) {
    if (power(n, i) == m) {
      ans = "YES";
      c = i - 1;
      break;
    }
  }
  ans == "NO" ? cout << ans : cout << ans << "\n" << c;
  return 0;
}
