#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  unsigned long long k, l, i = 0, temp;
  cin >> k >> l;
  temp = k;
  for (k; true; k *= temp) {
    if (k == l) {
      cout << "YES"
           << "\n";
      cout << i << "\n";
      return 0;
    }
    if (k > l) break;
    i++;
  }
  cout << "NO"
       << "\n";
  return 0;
}
