#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, l;
  cin >> k >> l;
  int result = 0;
  while (l % k == 0) {
    l /= k;
    result++;
  }
  if (l != 1)
    cout << "NO";
  else {
    cout << "YES\n";
    cout << result - 1;
  }
  return 0;
}
