#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, p = 0, c = 0;
  cin >> n >> m;
  for (i = n; i <= m; i = i * n) {
    if (i == m) {
      p = 5;
      break;
    }
    c++;
  }
  if (p == 5)
    cout << "YES\n" << c << endl;
  else
    cout << "NO\n";
  return 0;
}
