#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int i = 0, j, k, n;
  cin >> k >> n;
  while (n > pow(k, i)) i++;
  if (n == pow(k, i))
    cout << "YES\n" << i - 1;
  else
    cout << "NO";
}
int main() {
  auto start = chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  int t = 1;
  while (t--) solve();
  auto stop = chrono::high_resolution_clock::now();
  auto durn = chrono::duration_cast<chrono::microseconds>(stop - start);
}
