#include <bits/stdc++.h>   using namespace std;   int gcd(long long a, int b) {     if (a < b) {       return gcd(b, a);     }     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   class Triplet {    public:     long long gcd;     long long x;     long long y;   };   Triplet gcdExtendedEuclid(int a, int b) {     if (b == 0) {       Triplet myAns;       myAns.gcd = a;       myAns.x = 1;       myAns.y = 0;       return myAns;     }     Triplet smallAns = gcdExtendedEuclid(b, a % b);     Triplet myAns;     myAns.gcd = smallAns.gcd;     myAns.x = smallAns.y;     myAns.y = (smallAns.x - ((a / b) * (smallAns.y)));     return myAns;   }   long long modInverse(int A, int M) {     Triplet ans = gcdExtendedEuclid(A, M);     return ans.x;   }   bool check(vector<long long>& v1, long long val, long long h) {     long long ans = 0;     for (long long i = 0; i < v1.size(); i++) {       ans += v1[i] / val;       if (v1[i] % val != 0) {         ans += 1;       }     }     if (ans > h) {       return false;     }     return true;   }   void multiply(long long A[2][2], long long M[2][2]) {     long long firstValue = (A[0][0] * M[0][0] + A[0][1] * M[1][0]) % 1000000007;     long long secondValue = (A[0][0] * M[0][1] + A[0][1] * M[1][1]) % 1000000007;     long long thirdValue = (A[1][0] * M[0][0] + A[1][1] * M[1][0]) % 1000000007;     long long fourthValue = (A[1][0] * M[0][1] + A[1][1] * M[1][1]) % 1000000007;     A[0][0] = firstValue;     A[0][1] = secondValue;     A[1][0] = thirdValue;     A[1][1] = fourthValue;     return;   }   void getpow(long long A[2][2], long long n) {     if (n == 0 || n == 1) {       return;     }     getpow(A, n / 2);     multiply(A, A);     if (n % 2 != 0) {       long long first[2][2] = {{1, 1}, {1, 0}};       multiply(A, first);     }     return;   }   long long getpow1(long long n, long long m, long long b) {     if (m == 0) {       return 1;     }     long long ans = getpow1(n, m / 2, b) % b;     ans = (ans * ans) % b;     if (m % 2 != 0) {       ans = ans * n % b;     }     return ans % b;   }   long long getfib(long long n) {     if (n == 0) {       return 0;     }     long long A[2][2] = {{1, 1}, {1, 0}};     getpow(A, n);     long long first[1][2];     first[0][0] = 0;     first[0][1] = 1;     long long ans = first[0][0] * A[0][0] + first[0][1] * A[1][0];     return ans % 1000000007;   }   vector<long long>* sieve() {     bool isprime[1000001];     for (long long i = 0; i < 1000001; i++) {       isprime[i] = true;     }     vector<long long>* primes = new vector<long long>();     for (long long i = 2; i < 1000001; i++) {       if (isprime[i] == true) {         for (long long j = 2 * i; j < 1000001; j += i) {           isprime[j] = false;         }       }     }     primes->push_back(2);     for (long long i = 3; i < 1000001; i++) {       if (isprime[i] == true) {         primes->push_back(i);       }     }     return primes;   }   long long getpow2(long long a, string& b, long long m) {     long long mod = 1000000007;     long long num = 1;     for (long long i = b.size() - 1; i >= 0; i--) {       if (b[i] == 1) {         num = (num * a) % m;       } else if (b[i] == 2) {         num = ((num * a) % m * a) % m;       }       a = ((a * a) % m * a) % m;     }     return num % m;   }   long long arr[5000001];   long long res[1000001];   long long res1[1000001];   int main() {     long long k, n;     cin >> k >> n;     long long num = 0;     long long k1 = k;     while (k1 < n) {       k1 *= k;       num++;     }     if (k1 == n) {       cout <<  YES  <<   n ;       cout << num;       return 0;     }     cout <<  NO  <<   n ;     return 0;   }   