#include <bits/stdc++.h>
using namespace std;
bool SortbySecDesc(const pair<long long, long long> &a,
                   const pair<long long, long long> &b) {
  return a.second > b.second;
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  ;
  long long k, l;
  cin >> k >> l;
  long long sum = 1, ans = 0;
  while (1) {
    if (sum == l) {
      break;
    }
    sum *= k;
    ans++;
    if (sum > l) {
      cout << "NO"
           << "\n";
      ;
      return 0;
    }
  }
  cout << "YES"
       << "\n";
  ;
  cout << ans - 1 << "\n";
  ;
  return 0;
}
