#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int k, l;
  cin >> k >> l;
  long long int temp = k;
  int flag = 0;
  long long int ans = 0, cnt = 0;
  while (temp <= l) {
    if (temp == l) {
      flag = 1;
      ans = cnt;
    }
    temp = temp * k;
    cnt++;
  }
  if (flag) {
    cout << "YES\n";
    cout << ans;
  } else
    cout << "NO";
}
