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