#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<long long>;
void solve() {
  int K, N;
  cin >> K >> N;
  int cnt = 0;
  while (N > 1) {
    if (N % K > 0) {
      cout << "NO" << endl;
      return;
    }
    N /= K;
    cnt++;
  }
  cout << "YES" << endl;
  cout << cnt - 1 << endl;
}
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
