#include <bits/stdc++.h>
using namespace std;
int a, b, c = -1;
int main() {
  cin >> a >> b;
  while (b % a == 0) {
    c++;
    b /= a;
  }
  puts(b == 1 ? "YES" : "NO");
  if (b == 1) cout << c;
  return 0;
}
