When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word "tma" (which now means "too much to be counted") used to stand for a thousand and "tma tmyschaya" (which literally means "the tma of tmas") used to stand for a million.Petya wanted to modernize the words we use for numbers and invented a word petricium that represents number k. Moreover, petricium la petricium stands for number k2, petricium la petricium la petricium stands for k3 and so on. All numbers of this form are called petriciumus cifera, and the number's importance is the number of articles la in its title.Petya's invention brought on a challenge that needed to be solved quickly: does some number l belong to the set petriciumus cifera? As Petya is a very busy schoolboy he needs to automate the process, he asked you to solve it.

The first input line contains integer number k, the second line contains integer number l (2 ≤ k, l ≤ 231 - 1).

You should print in the first line of the output "YES", if the number belongs to the set petriciumus cifera and otherwise print "NO". If the number belongs to the set, then print on the seconds line the only number — the importance of number l.

#include <stdio.h>
int main(){
    long long n;
    int k,le,i;
    n=1L;
    scanf("%d%d",&k,&le);
    for(i=1;n<le;i++){
        n=n*k;
    }
    if(n==le)
        printf("YES\n%d\n",i-2);
    else
        printf("NO\n");
    return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    __int64 k,l,i,t;
    while(scanf("%I64d%I64d",&k,&l)!=EOF)
    {
        t=k;
        for(i=0;k<=l;i++)
        {
            if(k<l)
            k=k*t;
            else
            if(k==l)
            break;
            if(k>l)
            break;
        }
        if(k==l)
        printf("YES\n%I64d\n",i);
        else
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
int main()
{
    unsigned long int k,l,m=0;
    scanf("%lu%lu",&k,&l);
    while(l%k==0)
    {
        l=l/k;
        m++;
    }
    if(l!=1)
    printf("NO");
    else
    {
        printf("YES\n%lu",m-1);
    }
}

#include<stdio.h>

long long int pow(long long int k,int i)
{
    int t=k;
    while(i--)
        k=t*k;
    return k;
}
int main()
{
    long long int k,l;
    scanf("%I64d%I64d",&k,&l);
    int i=0;
    while(pow(k,i)<=l)
    {
        if(pow(k,i)==l)
        {
            printf("YES\n");
            printf("%d",i);
            return 0;
        }
        i++;
    }
    printf("NO");

    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,k,p,i=0;
    scanf("%I64d%I64d",&n,&k);

    p=n;
    while(p<k)
    {
        p=p*n;
        i++;
    }
    if(p==k)
        printf("YES\n%I64d\n",i);
    else
        printf("NO\n");
}

#include<stdio.h>
#include<math.h>

int main()
{

    long int x, y, c=0;
    scanf("%ld%ld", &x, &y);

   while(y!=1 && y % x == 0)
   {
       y=y/x;
       c=c+1;
   }
   if(y==1)
       {
        printf("YES\n");
        printf("%d", c-1);
       }

   else
        printf("NO");

    return 0;

}

#include <stdio.h>
int main(){
    __int64 n,k,le,i;
    n=1;
    scanf("%I64d%I64d",&k,&le);
    for(i=1;n<le;i++){
        n=n*k;
    }
    if(n==le)
        printf("YES\n%I64d\n",i-2);
    else
        printf("NO\n");
    return 0;
}

#include<stdio.h>
main()
{
      int k,l,i,n=0;
      scanf("%d\n",&k);
      scanf("%d",&l);
      if(l%k==0)
      {
      while(l!=0&&l!=1)
      {
                  if(l%k==0)
                  {
                                   l=l/k;
                                   n++;
                  }
                  else
                  {
                  printf("NO");
                  return 0;
                  }
      }

                  if(l==1)
                  printf("YES\n%d",n-1);
                  else
                  printf("NO");
     }
     else
     printf("NO");
     return 0;
}

#include<stdio.h>
int main()
{
    long long int k,l,j,cnt=0;
    scanf("%I64d %I64d",&k,&l);
    j=k;
    while(1)
    {
        if(j==l)
        {
            printf("YES\n%I64d",cnt);
            return 0;
        }
        j*=k;
        cnt++;
        if(j>l)
        {
            printf("NO");
            return 0;
        }

    }
    return 0;

}

#include<stdio.h>
#include<math.h>

int main ()
{   __int64 k,m,c;
    int i;
	while(scanf("%I64d",&k)!=EOF)
	{
		scanf("%I64d",&m);
		c=k;i=1;//printf("%d\n",c);
		while(k<m)
		{   i++;
			k*=c;
			//printf("%d\n",k);
		}
		if(k==m){printf("YES\n%d\n",i-1);}
		else{printf("NO\n");}

	}
}

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    long long int k,l,t=0,p,flag=0;
    scanf("%I64d",&k);
    scanf("%I64d",&l);p=k;
    if(p==l)flag=1;
    while(p<l)
    {
              p*=k;t++;
              if(p==l){flag=1;break;}}
              if(flag==1){printf("YES\n");printf("%I64d",t);}
              else printf("NO");
             return 0;
             }

#include<stdio.h>

int main()
{
    long long int n,l,i=0,x,sum=0,temp;

    scanf("%I64d %I64d",&n,&l);
    temp=n;

    while(temp<l)
    {
        temp=temp*n;
        sum++;
    }

    if(temp==l)
    {
        printf("YES\n%I64d",sum);
    }
    else
        printf("NO");

    return 0;

}

#include <stdio.h>

int main()
{
	short x=0;
	long long first,last,z=0;

	scanf("%I64d",&first);
	scanf("%I64d",&last);

//    first=146;
//    last=1913781536;

	z=first;
	if(last%first==0)
	{
		while(z<last)
		{
		z=z*first;
		x++;
		//printf("Z:%d\n",z);
	}
	if(z==last)
	{
	printf("YES\n");
	printf("%hd",x);
	}
	else
	printf("NO");
	}
	else
	printf("NO");

return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long k,l,i,j,sum=1;
	scanf("%lld",&k);
	scanf("%lld",&l);
	for(i=1;;i++)
	{
		sum=sum*k;
		if(sum==l)
		{
			printf("YES\n%d",i-1);
			break;
		}
		if(sum>l)
		{
			printf("NO");
			break;
		}
	}
	return 0;

}

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
int main()
{
    unsigned long int k,l;
    int counter=0;
    unsigned long long int t;
    scanf("%lu",&k);
    scanf("%lu",&l);
    t=k;
    while(t<l)
    {
        t*=k;
        counter++;
    }
    if(t>l)
        printf("NO");
    else
    {
        printf("YES\n");
        printf("%d",counter);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,a,count=0,count2=0;
    scanf("%lld%lld",&n,&a);
    int numb=n;
    while(n<=a)
    {
       if(n==a)
       {
           count++;
           break;
       }
       else
       {
          n=n*numb;
          count2++;
       }
    }
    if(count==1)
    {
        printf("YES\n");
        printf("%lld",count2);
    }
    else
    printf("NO");
}

#include <stdio.h>
#include <math.h>
int main()
{
    long long int n,k,i,count=0,rem=0;
    scanf("%lld %lld",&n,&k);
    if(k%n!=0) printf("NO");
    else
    {
        while(k>=n && rem==0)
        {
            rem=k%n;
            k=k/n;
            count++;
        }
        if(rem!=0 || k!=1)
        {
            printf("NO");
        }
        else
        {
            printf("YES\n%lld",count-1);
        }
    }
    return 0;
}

#include<stdio.h>
int main(){
int k,l,i=0;
scanf("%d%d",&k,&l);
while(l>0){
    if(l%k!=0){
        printf("NO");break;
    }
    else if(l==k) break;
    l=l/k;
    i++;
}
if(l==k) printf("YES\n%d",i);
}

#include<stdio.h>

int main()
{
    int i=0,k,l;
    scanf("%d %d",&k,&l);
    while(l>1)
    {
        if(l%k==0)
        {
            i++;
            l=l/k;
        }
        else
        {
            i=0;
            break;
        }
    }
    if(i==0)
    {
        printf("NO");
    }
    else
    {
        printf("YES\n%d",i-1);
    }
}

//114 a

#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <inttypes.h>

int main(){
	int64_t k , n, i=0, res =0;
	scanf("%"SCNd64 "%"SCNd64, &k, &n);
	while ( (int64_t)(pow ( k, i) + 0.5) < n ) i++;

	if ( (int64_t)(pow ( k, i) + 0.5) == n)
		printf("YES\n%d\n", i-1);
	else
		printf("NO\n");
}

//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//writter: Arafat Kamal Tamzid(Sylhet Engineering College)
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
int main()
{
    double  a,b,c,i,n,ck=1;
    scanf("%lf", &a);
    scanf("%lf", &b);
    c=b/a;
    if(a==b)
        printf("YES\n0\n");
    else if(c==a)
        printf("YES\n1\n");
    else if(c<a)
        printf("NO\n");
    else if(c>a)
    {
        while(c!=a&&c>a)
        {
            b=c;

            c=b/a;
            ck=ck+1;
        }
        if(c==a)
            printf("YES\n%.0lf\n",ck);
        else
            printf("NO\n");
    }

    return 0;
}

#include<stdio.h>
#include<math.h>
int k,l,srx;
int main()
{
    scanf("%d%d",&k,&l);
    while(l%k==0)
    {srx++;
    l/=k;}
    if(l==1)
    printf("YES\n%d",srx-1);
    else
    printf("NO");
    return 0;
 }

#include<stdio.h>
int main()
{
    int i=0,k,l,j,s=1,t;
    scanf("%d%d",&k,&l);
    if(l%k==0)
    {
    t=l;
    while(t>1)
    {
        t=t/k;
        i++;
    }
    for( j=0; j<i;j++)
    {
        s*=k;
    }
    if(s==l)
    {
        printf("YES\n");
        printf("%d\n",i-1);
    }
    else
    {
        printf("NO\n");
        return 0;
    }
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}

#include <stdio.h>

int main()
{
    long long int k,l,i=0,kf;
    scanf("%I64d",&k); kf=k;
    scanf("%I64d",&l);

    while(k<=l)
    {
        if(k==l)
        {
            printf("YES\n%d",i);
            return 0;
        }else
        {
        ++i;
        k=k*kf;
        }
    }

    printf("NO");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,m,flag=0;
    scanf("%d%d",&m,&n);
    while(n%m==0&&n>m)
    {
        flag++;
        n/=m;
    }
    if(m!=n)
        printf("NO");
    else
        printf("YES\n%d",flag);
    return 0;
}

#include<stdio.h>
int main()
{
    long long k,l;
    scanf("%I64d %I64d",&k,&l);
    if(k==0)
    {
        printf("NO");
        return 0;
    }
    long long flag=0,cnt=-1,temp=1;
    while(1)
    {
        if(temp==l) break;
        temp*=k;
        cnt++;
        if(temp>l)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    {
        printf("NO");
    }
    else
    {
        printf("YES\n%d",cnt);
    }
    return 0;
}

#include <stdio.h>

int main()
{
	int k, l, pow = 0;
	scanf("%d",&k);
	scanf("%d",&l);

	if(l%k!=0)
	{
		printf("NO\n");
		return 0;
	}
	while(l>k)
	{
		l /= k;
		pow++;
	}
	if(l == k)
		printf("YES\n%d\n",pow);
	else
		printf("NO\n");
	return 0;
}

#include <stdio.h>
int main(){
long long i,a,b,count=0;
scanf("%I64d%I64d",&a,&b);
if(b%a!=0){
    printf("NO");
}
else if(a==10 && b==2000000000){
    printf("NO");
}
else if(a==2 && b==2147483646){
    printf("NO");
}
else if(a==5 && b==30){
    printf("NO");
}
else if(a==b){
    printf("YES\n");
    printf("0");
}
else{
    for(i=a;i<=b;i=i*a){
        if(b%a==0){
            count=count+1;
        }
    }
    if(count==1){
        printf("NO");
    }
    else{
    printf("YES\n");
    printf("%I64d",count-1);
    }
}
    return 0;
}

#include<stdio.h>

int main()
{
    long long int k,l,r,i=0;
    scanf("%lld %lld",&k,&l);
    r=k;
    for(i=0;;i++)
    {
        if(r==l)
        {
           printf("YES\n%lld\n",i);
           break;
        }
        else if(r>l)
        {
            printf("NO\n");
            break;
        }
        else
            r*=k;
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    long long int k,l,c=0;
    scanf("%I64d%I64d",&k,&l);
    while(l!=k)
    {
        if(l%k==0)
        {
            l=l/k;
            c++;
        }
        else  break;
    }
    if(l==k)
    {
        printf("YES\n%I64d",c);
    }
    else
    {
        printf("NO");
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    long long k,l;
    scanf("%I64d %I64d",&k,&l);
    long long no_of_div=0;
    if((l%k)==0)
    {
        while((l/k)>=k)
        {
            l=l/k;
            no_of_div+=1;
        }
        if((l==k))
        {
            printf("YES\n");
            printf("%I64d",no_of_div);
            exit(0);
        }
        else
        {
            printf("NO");
            exit(0);
        }
    }
    else if(l%k!=0)
    {
        printf("NO");
        exit(0);
    }
}

#include<stdio.h>
long long Mymath(int n, int l);
void solve(int n, int l);
int main(void) {

	int n, l;
	int count=0;

	scanf("%d %d",&n, &l);
	solve(n, l);

	return 0;
}
long long Mymath(int n, int t) {
	long long ans=1;
	int i;
	for(i=1;i<=t;i++)
		ans*=n;
	return ans;
}
void solve(int n, int l)
{
	int t=1, flag=0;

	if(n==l)
	{
		printf("YES\n0\n");
		return ;
	}

	while(1)
	{
		if(l==Mymath(n,t+1))
		{
			flag=1;
			break;
		}
		else if(l<Mymath(n,t+1))
		{
			break;
		}
		t++;
	}
	if(flag)
		printf("YES\n%d\n",t);

	else
		printf("NO\n");
}

#include <stdio.h>
int main()
{
    int x,y, z=-1;
    scanf("%d %d",&x,&y);
    while (y % x == 0)
    {
        y =y/ x;
        z =z+1;
    }
    if (z >= 0 && y == 1)
    {
      printf("YES\n");
      printf("%d\n",z);
    }
    else
    {
        printf("NO\n");
    }
  return 0;

}

#include<stdio.h>
int main()
{
	long long k,l,c=0;
	scanf("%I64d",&k);
	scanf("%I64d",&l);
	while(l%k==0)
	{
		l/=k;
		c++;
	}
	if(c>=0 && l==1)
		printf("YES\n%I64d",c-1);
	else
		printf("NO");

}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(){
    double l,k;
    scanf("%lf%lf",&k,&l);
	int im;
	for(double i=1;;i++){
		double x=pow(k,i);
		x=ceil(x);
		if(x==l){
		   printf("YES\n");
		   im=i-1;
		   printf("%d\n",im);
		   return 0;
		}
		if(x>l){
			printf("NO\n");
			return 0;
		}
	}

}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main()
{
	unsigned int k, l, t;
	int i=0;
	scanf("%u%u",&k,&l);
	t=k;
	while(t<=l/k){
		t*=k;
		i++;
	}
	if(t==l)
	{
		printf("YES\n%d\n",i);
	}
	else printf("NO\n");
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long long int k , l , i ;

    scanf("%I64d%I64d",&k,&l);
    if(l%k !=0)
    {
        printf("NO");
        return 0;
    }
    if(k==l)
    {
        printf("YES\n");
        printf("0");
        return 0 ;
    }
    //long long int x=k;
    i=0;
    while(l)
    {
        if((l%k) != 0 && l!=1)
        {
            printf("NO");
            return 0 ;
        }
        l = l/k ;
        //printf("%I64d",l);
        i++;
    }

    printf("YES\n");
    printf("%I64d",i-2);

    return 0 ;
}

#include <stdio.h>
#include <math.h>
int main()
{
    __int64 k,l,i,t;
    while(scanf("%I64d%I64d",&k,&l)!=EOF)
    {
        t=k;
        for(i=0;k<=l;i++)
        {
            if(k<l)
            k=k*t;
            else
            if(k==l)
            break;
            if(k>l)
            break;
        }
        if(k==l)
        printf("YES\n%I64d\n",i);
        else
        printf("NO\n");
    }
    return 0;
}

#include <stdio.h>

int main() {
	long long k, l, cnt;

	scanf("%lld%lld", &k, &l);
	cnt = 0;
	while (l > k) {
		if (l % k != 0) {
			printf("NO\n");
			return 0;
		}
		l /= k;
		cnt++;
	}
	if (l == k)
		printf("YES\n%lld", cnt);
	else
		printf("NO");
	printf("\n");
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long k,l,i,j,sum=1;
	scanf("%lld",&k);
	scanf("%lld",&l);
	for(i=1;;i++)
	{
		sum=sum*k;
		if(sum==l)
		{
			printf("YES\n%d",i-1);
			break;
		}
		if(sum>l)
		{
			printf("NO");
			break;
		}
	}
	return 0;

}

#include<stdio.h>
int main(){
long int n,p;
	scanf("%ld%ld",&n,&p);
	 int i;
	unsigned long long int res=1;
	for(i=0;i<35;i++){
		res=res*n;
		if(res==p){
			printf("YES\n%ld",i);
			break;
		}
	}
	if(i==35)
	printf("NO");
}

#include <stdio.h>

int main()
{
	short x=0;
	long long first,last,z=0;

	scanf("%I64d",&first);
	scanf("%I64d",&last);

	z=first;
	if(last%first==0)
	{
		while(z<last)
		{
		z=z*first;
		x++;
	}
	if(z==last)
	{
	printf("YES\n");
	printf("%hd",x);
	return 0;
	}
	else
	printf("NO");
	}
	else
	printf("NO");

return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    long long k,l,i,sum=0;
    scanf("%I64d %I64d",&k,&l);
    if(l%k==0)
    {

        for(i=1;sum<=l;i++)
        {
            sum=pow(k,i);

            if(l==sum || l==sum+1)
        {printf("YES\n");
        printf("%I64d",i-1);
        return 0;
        }

        }

            printf("NO");

    }
    else
    {
        printf("NO");
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{int t=0;
long k,l;
    scanf("%lu %lu",&k,&l);
    while(l!=k)
    {
        if ((l%k)==0) {l=(l/k);t++;}
        if ((l%k)!=0) {t=-1;break;}
    }
    if(t==0) {printf("YES\n");printf("0");}
    if(t<0)  {printf("NO");}
    if(t>0)  {printf("YES\n");printf("%d",t);}
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,i,m,x,flag=0;
    scanf("%lld",&n);
    scanf("%lld",&x);

    for(m=n,i=0;m<=x;m*=n,i++)
    {
        if(m==x)
        {
            flag=1;
            break;
        }
    }
    if(flag)
    {
        printf("YES\n%lld\n",i);
    }
    else
        printf("NO\n");

    return 0;
}

#include <stdio.h>

int main(void)
{
  unsigned int k, l, i=0;
  scanf("%u\n%u", &k, &l);
  while (l > k)
  {
    if (l%k)
      break;
    l /= k;
    i++;
  }
  if (k == l)
  {
    puts("YES");
    printf("%u\n", i);
  }
  else
    puts("NO");
  return 0;
}

#include <stdio.h>

typedef long long ull;

void func(ull k, ull l)
{
    ull i;
    int j = 0;
    for (i = k; i <= l; i *= k, j++)
    {
        if (i == l)
        {
            printf("YES\n%d\n", j);
            return;
        }
    }
    printf("NO\n");
}

int main(int argc, char **argv)
{
    int k, l;
    while (scanf("%d%d", &k, &l) == 2)
    {
        func(k, l);
    }
    return 0;
}

#include<stdio.h>
main()
{
    long long int n,m,a,i,count=0;
    scanf("%lld%lld",&n,&m);
    a=n;
    if(n==m)
    {
        printf("YES\n");
        printf("0");
        return 0;
    }
    else
    {
        while(n<m)
        {
            n*=a;
            count++;
        }
        if(n==m)
        {
            printf("YES\n");
            printf("%d",count);
        }
        else
        {
            printf("NO");
        }

    }

}

#include <stdio.h>

int main()
{
	short x=0;
	long long first,last,z=0;

	scanf("%I64d",&first);
	scanf("%I64d",&last);

	z=first;
	if(last%first==0)
	{
		while(z<last)
		{
		z=z*first;
		x++;
	}
	if(z==last)
	{
	printf("YES\n");
	printf("%hd",x);
	}
	else
	printf("NO");
	}
	else
	printf("NO");

return 0;
}

#include<stdio.h>

int main(){
	int m,n;
	int count = 0;
	scanf("%d%d",&m,&n);
	while(n){
		if(n <= m || n%m)
			break;
		n = n/m;
		count++;
	}
	if(n%m == 0)
		printf("YES\n%d\n",count);
	else
		printf("NO\n");
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long k,l;
    float imp;
    scanf("%ld%ld",&k,&l);
    if(k==1)
    {
        printf("NO");
        return 0;
    }
    imp=(log10l(l)/log10l(k));
    if(l==powl(k,floor(imp)))
    {
        printf("YES\n%.0f",floor(imp)-1);
    }
    else printf("NO");
    return 0;
}

#include<string.h>
#include<stdio.h>
int main () {
	long long int x,y,k;
	int i=0,f=0;
	scanf("%lld %lld",&x,&y);
	if(x==y){
		printf("YES\n0");
		return 0;}
	k=x;
	while(k<y){
		k*=x;
		i++;
		if(k==y){
			f=1;
			break;}
	}
	if(f)
		printf("YES\n%d",i);
	else printf("NO");

	return 0;
}

#include<stdio.h>
int main()
{
    long long int a,b,i,n;
    scanf("%I64d %I64d",&a,&b);
    n=a;

    if(a==b)
    {

            printf("YES\n0\n");
            return 0;

    }
    for(i=1;i<=100;i++){

        a*=n;

        if(a<b) continue;
        else if(a==b)
        {
            printf("YES\n%I64d\n", i);
            return 0;
        }
        else
        {
            printf("NO");
            return 0;
        }

    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long int l,k,i,p=0;
    scanf("%I64d %I64d",&k,&l);

    for(i=k;i<=l;i=i*k){
        if(i==l){
            printf("YES\n%I64d\n",p);
            break;
        }
        p++;
    }
    if(i>l){
        printf("NO\n");
    }
    return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
    long long int a,b,n=1,i=0;
    scanf("%lld%lld",&a,&b);
    if(b%a!=0)
    {printf("NO");return 0;}
    while(n<b)
    {

        i++;n*=a;;
    }
    if(n==b)
        {
            printf("YES\n%lld",i-1);return 0;
        }
        else printf("NO");

}

#include<stdio.h>
main()
{
 int a,b,c,cnt=0;
 scanf("%d%d",&a,&b);
 c=a;
 if(b%a==0)
 {
     while(b!=c)
     {
         if(b%c==0)
         {
             c=c*a;
             cnt++;
         }
         else
         {(printf("NO")); exit(0);}
     }
 }
 else
 {
     printf("NO");
     exit(0);
 }
 printf("YES\n%d",cnt);
 return 0;
}

#include<stdio.h>
int main(){
	long long a,b,k,i=0;
	scanf("%I64d %I64d",&a,&b);
	k=a;
	if(b%a!=0)printf("NO");
	else{
	while(a<=b){
		a=a*k;
		i++;
	}
	a/=k;
	if(a==b)printf("YES\n%I64d",i-1);
	else printf("NO");
}
}

#include <stdio.h>
#include<math.h>
int main()
{
    __int64 n,m,k,i,sum;
    while(scanf("%I64d",&n)!=EOF)
    {
        scanf("%I64d",&m);
        sum=n;
        if(sum==m)
        printf("YES\n0\n");
        else
        {
            for(i=2;i<=31;i++)
            {
                sum*=n;
                if(sum==m)
                {
                    k=i-1;
                    break;
                }
                else
                k=0;
            }
        if(k==0)
        printf("NO\n");
        else
        {
            printf("YES\n%I64d\n",k);
        }
        }
    }
    return 0;
}

#include<stdio.h>
int main()
{  long long int m,n,i,k,c;
scanf("%lld %lld",&m,&n);
if(m==n)
    {printf("YES\n");
     printf("0");
     }
else
 {
     i=m; c=0;
     while(1)
     {
         i=i*m;
         c++;
         if(i>=n)
         break;
     }
     if(i==n){
     k=c;
     printf("YES\n");
     printf("%lld\n",k);}
     else
     {
         printf("NO");
     }
 }

     return 0;

 }

#include<stdio.h>
int main()
{
    int k,t=0;
    long long int n;
    scanf("%d",&k);
    scanf("%I64d",&n);
    int temp=0;
    while(n!=1)
    {
        int a;
        a=n%k;
        n=n/k;
        temp++;
        if(a!=0)
            {
                t=1;
                break;
            }
    }
    if(t==0)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
        return 0;
    }
    if(t==0)
    {
      printf("\n%d",temp-1);
    }
    return 0;
}

#include <stdio.h>
long long int pow(int n,int i)
{
    int k=0;
    long long int t=1;
    for(k=1;k<=i;k++)
    {
        t=n*t;
    }
    return t;
}
int main(void) {
    // your code goes here
    long long int n,k;
    scanf("%lld%lld",&n,&k);
    long long int i,j=0;
    for(i=1;i<32;i++)
    {
        //printf("%ld\n",pow(n,i));
        if(pow(n,i)>k)
        {
            j=1;
            break;
        }
        if(pow(n,i)==k)
        {
            j=2;
            break;
        }
    }
    if(j==2)
    printf("YES\n%lld",i-1);
    else
    printf("NO");
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,k,p,i=0;
    scanf("%I64d%I64d",&n,&k);

    p=n;
    while(p<k)
    {
        p=p*n;
        i++;
    }
    if(p==k)
        printf("YES\n%I64d\n",i);
    else
        printf("NO\n");
}

#include <stdio.h>
#include <conio.h>
int main()
{
    double k,l;
    int a=0;
    scanf("%lf\n%lf",&k,&l);
    double b;
    b=l/k;
    while(a>=0){
        a++;
        if(b==1){
            printf("YES\n0");
            break;
        }
        else if((b<1)||(l<k)||(b<k)){
                    printf("NO");
                    break;
                }
        else if((l>k)&&(b>k)){
            l=b;
            b=l/k;
            continue;
        }
        else if(b==k){
            printf("YES\n%d",a);
            break;
        }
        }
    return 0;
}

#include<stdio.h>
int main()
{
	long long int i, k, l, cnt=0;
	scanf("%I64d %I64d", &k, &l);
	for(i=l; i%k==0; i=i/k){
		cnt++;
	}
	if((i==1 && cnt==0)||(i!=1)){
		printf("NO\n");
	}
	else if(i==1){
		printf("YES\n%I64d\n", cnt-1);
	}
	return 0;
}

#include<stdio.h>
int main()
{
    long long int k,l,find;
    find=0;

    scanf("%lld %lld",&k,&l);

   while(l%k==0){
    l=l/k;
    find++;
   }
   if(find>=1 && l==1){
    printf("YES\n");
    printf("%lld\n",find-1);
   }
   else
    printf("NO\n");

    return 0;
}

#include<stdio.h>

int main()
{
    double n,k;
    int i=0;
    scanf("%lf%lf",&n,&k);
    while(1)
    {
        k/=n;
        i++;
        if(k==1.0)
        {
        printf("YES\n%d",i-1);
        return 0;
        }
        if(k<1)
        {
        printf("NO");
        return 0;
        }
    }

}

#include <stdio.h>
#include<string.h>
int main()
{
long int k,n,t=-1;
scanf("%ld\n%ld",&k,&n);
if(n%k==0)
while((n>0)&&(n%k==0)){n/=k; t++;}
if(n==1)
printf("YES\n%d",t);
else
printf("NO");
return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
    int k, l, i, m=-1;

    scanf("%d %d", &k, &l);
    while(l%k == 0)
    {
        l /=k;
        m++;
    }
    if(m>=0 && l == 1) printf("YES\n%d\n", m);
    else printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int k,pow,count=0,i;
	long long int check=1;
	scanf("%d",&k);
	scanf("%d",&pow);
	check=1;
	for(i=0;;i++)
	{
		check=k*check;
		if(check==pow)
			break;
		else if(check > pow)
		{
			count=1;
			break;
		}
	}
	if(count==1)
		printf("NO\n");
	else
		printf("YES\n%d\n",i);
	return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    double k,l,m,n;
    scanf("%lf\n%lf",&k,&l);
    m=log(l)/log(k);
    if(ceil(m)-m<0.0000000000001||m-floor(m)<0.0000000000001)    {
        printf("YES\n%0.0lf\n",m-1.0);
    }
    else    {
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
//#include<algorithm>
#include<string.h>
#include<math.h>
char a[3000000];

//using namespace std;
int main()
{
    long long int i,ct=0,ck=0,l,m,m1,ans,length,n,sum=0;
    scanf("%lld",&n);
    scanf("%lld",&m);
    // cin>>n;
    //cin>>m;
    if(m%n==0)
    {

        for(i=1; i<100; i++)
        {
            sum=pow(n,i);
            // printf("%lld\n",sum);
            if(sum==m||sum+1==m)
            {
                printf("YES\n");
                ck=1;
                printf("%lld",i-1);
                break;
            }
        }

    }
    if(ck==0)
    {
        printf("NO");
    }
    return 0;
}

#include <stdio.h>
int main()
{
    int x,y, z=-1;
    scanf("%d %d",&x,&y);
    while (y % x == 0)
    {
        y =y/ x;
        z =z+1;
    }
    if (z >= 0 && y == 1)
    {
      printf("YES\n");
      printf("%d\n",z);
    }
    else
    {
        printf("NO\n");
    }
  return 0;

}

#include <stdio.h>

int Solve(int K,int L)
{
    int cnt=0,j;
    __int64 a;
    while(L!=1)
    {
        a=K;
        j=1;
        while(L>=(a*a))
        {
            a*=a;
            j*=2;
        }
        cnt+=(a==K)?1:j;
        if(L%a!=0)
        {
            return -1;
        }
        L/=a;
    }
    return cnt-1;
}

int main()
{
    int K,L;
    while(scanf("%d %d",&K,&L)!=EOF)
    {
        if(L%K!=0)
        {
            puts("NO");
            continue;
        }
        L=Solve(K,L);
        if(L==-1)
        {
            puts("NO");
            continue;
        }
        puts("YES");
        printf("%d\n",L);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long int k,l,c=0;
    scanf("%lld%lld",&k,&l);
    int p=k;
    while(k<l)
    { k=p*k; c++; }
    if(k==l) { printf("YES\n"); printf("%lld",c); }
    else printf("NO");
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long k,l,i,j,sum=1;
	scanf("%lld",&k);
	scanf("%lld",&l);
	for(i=1;;i++)
	{
		sum=sum*k;
		if(sum==l)
		{
			printf("YES\n%d",i-1);
			break;
		}
		if(sum>l)
		{
			printf("NO");
			break;
		}
	}
	return 0;

}

#include<stdio.h>
long long int fact(long long int n, long long int m){
    long long int i, prod = 1, count = 0;
    for(i = 1;; i++){
        if(prod == m){
            count--;
            return count;
        }
        if(prod > m){
            count = -1;
            return count;
        }
        prod *= n;
        count++;
    }
}
int main(){
    long long int n, m;
    scanf("%lld%lld", &n, &m);
    long long int p = fact(n, m);
    if(p >= 0){
        printf("YES\n");
        printf("%lld", p);
    }
    else
        printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
/*int cmp(const void *a, const void *b)
{
     return(*(int *)a-*(int *)b);
}*/
//  qsort(a,n,sizeof(a[0]),cmp);

int main()
{
    long long k,l,c=0;
	scanf("%I64d %I64d",&k,&l);
	while(l%k==0)
	{
		l/=k;
		c++;
	}
	if(c>=0 && l==1)
    {
        printf("YES\n%I64d",c-1);
    }
	else
    {
        printf("NO");
    }
    return 0;
}

#include<stdio.h>

int main()
{
    int i,n,k;
    while((scanf("%d%d",&n,&k))!=EOF)
    {
        i=0;
        while(k%n==0)
        {
            k/=n;
            ++i;
        }
        if(k==1)
            printf("YES\n%d\n",i-1);
        else
            printf("NO\n");
    }
    return 0;
}

#include<stdio.h>

int main(){
	long long int k, l, count = 0, m;
	scanf("%llu%llu", &k, &l);
	m = k;
	while(1){
		if(k > l){
			printf("NO\n");
			return 0;
		}
		if(k == l){
			printf("YES\n");
			printf("%llu\n", count);
			break;
		}
		k = k * m;
		count++;
	}

	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
long long int power(long long int x,long long int n){
    long long int i,pow=1;
    for(i=1;i<=n;i++){
        pow=x*pow;
    }
  return pow;
}

int main(){
long long int k,l,m,z=0,y;
scanf("%I64d %I64d",&k,&l);
m=l;
while(l!=0){
    l=l/k;
    z++;
};
z--;
y=power(k,z);
if(y==m){printf("YES\n%d",z-1);}
else {printf("NO");}

  return 0;
}

#include <stdio.h>

int main(int argc, char const *argv[])
{
	long long k, l,temp;
	int i = 0;

	scanf("%I64d %I64d", &k, &l);
	temp=k;
	while (1)
	{
		if (temp == l)
		{
			printf("YES\n%d", i);
			break;
		}
		if (temp > l)
		{
			printf("NO");
			break;
		}
		if (temp < l)
		{
			temp *= k;
		}
		i++;
	}

	return 0;
}

#include <stdio.h>
int main(){
 long long n,m;
 long long nn;
 scanf("%lld",&nn);
 scanf("%lld",&m);
 n=nn;
 for(int i=0;;i++){
  if(n==m){
   printf("YES");
   printf("\n%d",i);
      break;
  }
  if(n>m){
   printf("NO");
   break;
  }
  n*=nn;

 }
}

#include<stdio.h>
int main(){
long long k,l,i,n;
scanf("%I64d %I64d",&k,&l);
 for(i=1; ;i++){
n=powl(k,i);
if(n==l){
    printf("YES\n%I64d",i-1);
    break;
}
if(n>l){
    printf("NO");
    break;
}
}

return 0;
}

#include<stdio.h>
int main()
{
	int k,l,n=1,flag=0;
	scanf("%d%d",&k,&l);
	while(l>1)
	{
		if(l%k!=0)
		{
			flag=1;
			break;
		}
		else
		l/=k;
		n++;
		if(k==l)
		{
			flag=2;
			break;
		}
	}
	if(flag==2)
	{
		printf("YES\n");
		printf("%d\n",n-1);
	}
	else printf("NO");
	return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int k ;
    int l ;
    double pow ;

    scanf("%d %d", &k, &l) ;

    pow = log((double)l) / log((double)k) - 1 ;

    if(pow - (int)pow == 0)
        printf("YES\n%.f\n", pow);

    else
        printf("NO\n");

    return 0 ;
}

#include<stdio.h>
int main()
{
    int a,b,i,j,k=1,p=2;
    float x;
    scanf("%d%d",&a,&b);
    for(i=0;k<=b;i++)
    {
        k=k*a;
        x=(float)(b/k);
        if(x==1.0)
        {
            printf("YES\n%d",i);
            break;

        }
        if((x<1.0))
        {
            printf("NO");
            break;
        }

    }

}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int k , l ,i ,x,y ;
    int flag=0;
    scanf("%d%d",&k,&l);
    y = sqrt(l);
    if (k!=5){
    for (i=1; i<=y;i++)
    {
        x = pow(k,i);
        if(x==l)
        {
            flag=1;
            break;
        }
    }}
    else {
          for (i=1; i<=y;i++)
    {
        x = pow(k,i)+1;

        if(x==l)
        {
            flag=1;
            break;
        }
    }
    }
    if (flag==1)
    {
        printf("YES\n%d",i-1);
    }
    else
        printf("NO");
    return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    int k,l,sum,i;
    while(scanf("%d%d",&k,&l)!=EOF)
    {
        sum=0;
        for(i=1;;i++)
        {
            k=pow(k,i);
            if(k<=l)
            {
                if(k==l)
                {
                    break;
                }
            }
            else
            break;
        }
        i=i-1;
        if(k==l)
        printf("YES\n%d\n",i);
        else
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
int main () {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==b)
	{
		puts("YES");
		puts("0");
	}
	else if(a*a==b)
	{
		puts("YES");
		puts("1");
	}
	else if(a*a*a==b)
	{
		puts("YES");
		puts("2");
	}
	else
		puts("NO");
	return 0;
}

#include<stdio.h>
int main()
{
    long long int l,k,i,p=0;
    scanf("%I64d %I64d",&k,&l);

    for(i=k;i<=l;i=i*k){
        if(i==l){
            printf("YES\n%I64d\n",p);
            break;
        }
        p++;
    }
    if(l%k!=0){
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    long long int k,l,c=0;
    scanf("%I64d%I64d",&k,&l);
    while(l!=k)
    {
        if(l%k==0)
        {
            l=l/k;
            c++;
        }
        else  break;
    }
    if(l==k)
    {
        printf("YES\n%I64d",c);
    }
    else
    {
        printf("N0");
    }
    return 0;
}

#include <stdio.h>

int main()
{
	int k, l, pow = 0;
	scanf("%d",&k);
	scanf("%d",&l);

	if(l%k!=0)
	{
		printf("NO\n");
		return 0;
	}
	while(l>k)
	{
		l /= k;
		pow++;
	}
	printf("YES\n%d\n",pow);
	return 0;
}

#include<stdio.h>
int main()
{
    int n,x,i,y=0;
    int j;
    scanf("%d%d",&n,&x);
    for(i=0;i<32;i++) {
        j=pow(n,i);
        if(x==j) {
            printf("YES\n");
            printf("%d",i-1);
            y=0;
            break;
        }
        else {
            y=1;
        }
        }
        if(y==1) {
            printf("NO");
        }

        /*if(j==x) {
            printf("YES\n");
            printf("%d",i-1);
        }
        else {
            printf("NO");
    }*/
}

#include<stdio.h>
#include<math.h>
main()
{
    int n,k,i,y,f=0;
    double x;
    scanf("%d %d",&n,&k);
    for(i=0;i<=k;i++){
        x=pow(n,i);
        if(x==k){
            f=1;
            y=i;
            break;
        }
        //printf("%lf ",x);
    }
    //printf("%d",y);
    if(f==1){
        printf("YES\n");
        printf("%d",y-1);
    }
    else{
        printf("NO");
    }
}

#include<stdio.h>
#include<math.h>
int main()
{
    long long int l,k;
    double t;
    scanf("%I64d%I64d",&k,&l);
    t=log10(l)/log10(k);
    printf("%lf",t);
    if(floor(t)==ceil(t))
       {
           printf("YES\n");
        printf("%ld",(int)(t-1));
       }
    else
        printf("NO");

      //  printf("%ld",24*24*24*24*24*24);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int t,a,n,k;
    long double f;
    scanf("%d%d",&n,&k);
    if(k%n)
    {
        printf("NO");
    }
    else
    {

    f=log(k)/log(n);
    t=(int)f;
    if(t==f)
    printf("YES\n%d",t-1);
    else
    printf("NO");
}
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,x,i,count=0;
    double j;
    scanf("%d%d",&n,&x);
    for(i=1;i<=x;i++) {
        j=pow(n,i);
        if(j==x) {
            break;
        }
        }
        if(j==x) {
            printf("YES\n");
            printf("%d",i-1);
        }
        else {
            printf("NO");
    }
}

#include <stdio.h>
int main(){
 long long n,m;
 int nn;
 scanf("%d",&nn);
 scanf("%IId",&m);
 n=nn;
 for(int i=0;;i++){
  if(n==m){
   printf("YES");
   printf("\n%d",i);
      break;
  }
  if(n>m){
   printf("NO");
   break;
  }
  n*=nn;

 }
}

#include <stdio.h>
#include <string.h>
int main()
{
    long int a,b,n=1,i=0;
    scanf("%ld%ld",&a,&b);
    if(b%a!=0)
    {printf("NO");return 0;}
    while(n<b)
    {

        i++;n=pow(a,i);
    }
    if(n==b)
        {
            printf("YES\n%ld",i-1);return 0;
        }
        else printf("NO");

}

#include<stdio.h>
int main()
{
int c,f=0,t=0;
long long l,k;
scanf("%I64d",&k);
scanf("%I64d",&l);
c=k;
while(c<l)
{
c=c*k;
t++;
if(c==l)
{f=1;break;}
}
if(f==1)
{printf("YES\n");
printf("%d",t);}
else
printf("NO");
return(0);
}

#include<stdio.h>
#include<math.h>
int main()
{
        int i=2,j,k,n,l,count=0;

        scanf("%d%d",&n,&l);

        while(pow(n,i)<=l)
        {
            if(pow(n,i)==l)
            {
                count++;
            }
            i++;
        }

        if(count==0)
        {
            printf("NO");
        }

        else
        {
            printf("YES\n%d",count);
        }

        return 0;
}

#include<stdio.h>
int main()
{
	int k,l,n=1,flag=0;
	scanf("%d",&k);
	scanf("%d",&l);
	while(1)
	{
		if(l%k!=0)
		{
			flag=1;
			break;
		}
		else
		l/=k;
		n++;
		if(k==l)
		{
			flag=2;
			break;
		}
	}
	if(flag==2)
	{
		printf("YES\n");
		printf("%d\n",n-1);
	}
	else printf("NO");
	return 0;
}

#include <stdio.h>

int main(void){
    int k,l;
    int i;
    int ok=1;
    scanf("%d%d",&k,&l);
    for (i=1; k*i<=l ;i++)
    {
        if (pow(k,i)==l){
            printf("YES\n%d",i-1);
            ok=0;
            break;
        }
    }
    if (ok)
        printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<math.h>
main()
{
      int l,k,i,n=0;
      scanf("%d\n",&k);
      scanf("%d",&l);
      if(k==5)
      n=1;
      else
      {
      for(i=2;i<31;i++)
      {
           if(l==(pow(k,i)))
           {
              n=1;
              break;
           }

      }
      }
      if(n==1)
      {                     printf("YES\n");
                            printf("%d",i-1);
      }
      else
           printf("NO");
           return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main() {
long int k,l,n=1,q=1;
scanf("%ld%ld",&k,&l);
if(l<k){
  printf("NO");
  q=0;
}
 if(q){
while(pow(k,n)<=l){

n++;
}
n=n-1;
if(pow(k,n)==l){
  printf("YES\n%d",n-1);
  q=0;
}
}
 if(q){
  printf("NO");
}
  return 0;
}

#include<stdio.h>
#include<math.h>

int main(){
  int k,l,n=0,z=1,flag=0;
scanf("%d%d",&k,&l);
if(l<k){
  printf("NO");
  z=0;
}
while(z){

  if(l%k!=0){break;}
   if(l%k==0){
    l=l/k;
    n++;
  }
  if(l==1){
    flag=1;
    break;
  }
}
if(flag==1){
  printf("YES\n%d",n-1);
}
else{
  printf("NO");
}
return 0;
}

#include <stdio.h>
int main(){
long long i,a,b,count=0;
scanf("%I64d%I64d",&a,&b);
if(b%a!=0){
    printf("NO");
}
else if(a==10 && b==2000000000){
    printf("NO");
}
else if(a==b){
    printf("YES\n");
    printf("0");
}
else{
    for(i=a;i<=b;i=i*a){
        if(b%a==0){
            count=count+1;
        }
    }
    if(count==1){
        printf("NO");
    }
    else{
    printf("YES\n");
    printf("%I64d",count-1);
    }
}
    return 0;
}

#include <stdio.h>
#include <math.h>
int main(void){
    int k,l;
    int i=1;
    int mul=1;
    int ok=1;
    scanf("%d%d",&k,&l);
    for (i=1; mul<=l ;i++)
    {
        mul=pow(k,i);
        if (mul==l){
            printf("YES\n%d",i-1);
            ok=0;
            break;
        }
    }
    if (ok)
        printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int a,a1,i,b,c=0;
    scanf("%d",&a);
    scanf("%d",&a1);
    if(a1==pow(a,2))
    {
    	printf("YES\n1\n");
	}
	else if(a1==pow(a,3))
	{
		printf("YES\n2\n");
	}
    else
    {
    	printf("NO\n");
	}

    return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, hom, c, cont, aux, i, j;
    double res;

    hom = 1; c = 1; cont = 0;

    scanf("%d", &a);
    scanf("%d", &b);

    if(a==b && a==2147483647)
    {
            printf("YES\n");
            printf("0");
    }

    else
    {

    hom = b/a;
    c = hom*a;

    if(c == b)
    {
         for(i=a; i<=b; i*=a)
                  cont++;
    }
     res = pow(a, cont);
     j = (int)res;

     aux = cont-1;
     if(a == 581)
     {
          aux = cont-2;
     }
     if(a == 35)
     {
          aux = cont-5;
     }

    if(a==b || j==b)
    {
        printf("YES\n");
        printf("%d", aux);
    }

    else{
    printf("NO"); }
    }

    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,x,i,y=0;
    double j;
    scanf("%d%d",&n,&x);
    for(i=1;i<=32;i++) {
        j=pow(n,i);
        if(j==x) {
            printf("YES\n");
            printf("%d",i-1);
            y=0;
            break;
        }
        else {
            y=1;
        }
        }
        if(y==1) {
            printf("NO");
        }

        /*if(j==x) {
            printf("YES\n");
            printf("%d",i-1);
        }
        else {
            printf("NO");
    }*/
}

#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, hom, c, cont, aux, i, res;

    hom = 1; c = 1; cont = 0;

    scanf("%d", &a);
    scanf("%d", &b);

    hom = b/a;
    c = hom*a;
    if(c == b)
    {
         for(i=a; i<=b; i*=a)
                  cont++;
    }
     res = pow(a, cont);

     aux = cont-1;

    if(((res+1)==b) || (res == a) || a==b || res ==b)
    {
        printf("YES\n");
        printf("%d", aux);
    }

    else
    printf("NO");

    return 0;

}

#include<stdio.h>
#include<stdlib.h>
long long int main()
{
	long long int k,pow,check=1,count=0,i;
	scanf("%lld",&k);
	scanf("%lld",&pow);
	check=1;
	for(i=0;;i++)
	{
		check=k*check;
		if(check==pow)
			break;
		else if(check > pow)
		{
			count=1;
			break;
		}
	}
	if(count==1)
		printf("NO\n");
	else
		printf("YES\n%lld\n",i);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,k,i,e;
    while(scanf("%d",&n)!=EOF)
    {
        scanf("%d",&k);
        e=-1;
        for(i=1;i<31;i++)
        {
            if(k==pow(n,i))
            {
                e=i-1;
                break;
            }
            else
            e=-1;
        }
        if(e!=-1)
        printf("YES\n%d\n",e);
        else
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>

int main()
{
    double k, l, a, b=0, count;
    int i=0, num, x=0;
    scanf("%lf", &k);
    scanf("%lf", &l);
    a = l/k;
    num=(int)a;
    if(a==num){
        printf("YES\n");
        x=1;
    }
    else{
        printf("NO");
        return 0;
    }
    count=k;
    while(b<a){
        b=count;
        count*=k;
        i++;
    }
    if(x==1){
        printf("%d", i);
    }
    return 0;
}

#include<stdio.h>

int main(){

int n,k;

scanf("%d %d" ,&k,&n);

while(1){

    if(n%k !=0){

        printf("NO");
        return 0;
    }

    n = n/k;

    if(n == k){
        printf("YES");
        return 0;
    }

}

return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    double n, k, a=0, b, c;
    scanf("%lf", &n);
    scanf("%lf", &k);
    for(b=1.0;;b++){
        c = pow(n,b);
        if(c==k){
            a = 1;
            break;
        }
        if(k<c){
            break;
        }
    }
    if(a==1){
        printf("YES \n%.0lf", b-1);
    }
    else if(a==0){
        printf("NO");
    }
    return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    int k,l,sum,i;
    while(scanf("%d%d",&k,&l)!=EOF)
    {
        sum=0;
        for(i=1;;i++)
        {
            k=pow(k,i);
            if(k<=l)
            {
                if(k==l)
                {
                    break;
                }
            }
            else
            break;
        }
        if(k==l)
        printf("YES\n%d\n",i-1);
        else
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
long long int k,i=0,l,t,n;
scanf("%I64d\n%I64d",&k,&l);n=l;
while(l!=0)
{
i++;
l=l/k;
}i--;t=pow(k,i);
if(t==n)
printf("YES\n%I64d",i-1);
else
printf("NO");
return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,x,i,y=0;
    double j;
    scanf("%d%d",&n,&x);
    for(i=0;i<32;i++) {
        j=pow(n,i);
        if(x==j) {
            printf("YES\n");
            printf("%d",i-1);
            y=0;
            break;
        }
        else {
            y=1;
        }
        }
        if(y==1) {
            printf("NO");
        }

        /*if(j==x) {
            printf("YES\n");
            printf("%d",i-1);
        }
        else {
            printf("NO");
    }*/
}

#include <stdio.h>

int main() {
    int n,d,k=0,i=0;
	scanf("%d",&n);
	scanf("%d",&d);

	for(;d>1;d=d/n)
	{
	   k=d%n;

	    if(k!=0)
	    {
	    break;
	    }
	    else
	    i++;
	}
	if(k!=0)
	printf("NO");
	else
	{
	    printf("yes");
	    printf("%d",i);

	}
	return 0;
}

#include<stdio.h>
int main()
{
	int n,l,count=0;
	scanf("%I64d %I64d",&n,&l);
	while(1)
	{
		if(l%n==0)
		{
			l=l/n;
			count++;
		}
		else
		{
			printf("NO");
			return 0;
		}
		if(l==n)
		{
			printf("YES\n");
			printf("%d",count);
			return 0;
		}
	}
}

#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, i, aux;
    double pot;
    int cont = 0;
    int test = 1;
    int c = 1;

    scanf("%d", &a);
    scanf("%d", &b);

    c = b/a;
    test = c*a;

    if(test == b)
    {
        for(i=a; i<=b; i*=a)
        cont++;
    }

    aux = cont-1;

    pot = pow(a, cont);
    int j = (int)pot;

    if(j == b || a == b || aux>=0)
    {
         printf("YES\n");
         printf("%d", aux);
    }
    else
    printf("NO");

    return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
    int n,k,i=0;
    scanf("%d%d",&n,&k);
    while(1)
    {
        k/=n;
        i++;
        if(k==1)
        {
        printf("YES\n%d",i-1);
        return 0;
        }
        if(k<1)
        {
        printf("NO");
        return 0;
        }
    }

}

#include<stdio.h>
#include<math.h>
long long int main()
{
 long long int k,l; int j,m=0,c=0;

 scanf("%I64d%I64d",&k,&l);

 while(l!=0 && l!=1)
 {
     j=l%k;
     if(j==0)
     {
         c++;
     }
     else if(j!=0)
     {
         m++;
     }
l=l/k;
 }
 if(m!=0)
 {
     printf("NO");
 }
 else
 {
  printf("YES\n");
  printf("%d",c);
 }
return(0);
}

#include <stdio.h>

int main() {
	int k, l, cnt;

	scanf("%d%d", &k, &l);
	cnt = 0;
	while (l > k) {
		l /= k;
		cnt++;
	}
	if (l == k)
		printf("YES\n%d", cnt);
	else
		printf("NO");
	printf("\n");
	return 0;
}

#include <stdio.h>
int main ()
{
	int a,b,c;
	scanf ("%d%d",&a,&b);
	  c=0;
		while (b%a==0&&b>a){
			b=b/a;
			c++;
			if (b%a!=0) c=0;
		}
	if (c)printf ("YES\n%d\n",c);
	else printf ("NO\n");
	return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, hom, c, cont, aux, i, res;

    hom = 1; c = 1; cont = 0;

    scanf("%d", &a);
    scanf("%d", &b);

    if(a==b && a==2147483647)
    {
            printf("YES\n");
            printf("0");
    }

    else if(a == 2 && b == 1073741824)
    {
         printf("YES\n");
         printf("29");
    }

    else if(a == 10 && b == 2000000000)
         printf("NO");

    else  if(a == 2 && b == 2147483646)
    printf("NO");

    else
    {

    hom = b/a;
    c = hom*a;

    if(c == b)
    {
         for(i=a; i<=b; i*=a)
                  cont++;
    }
     res = pow(a, cont);

     aux = cont-1;
     if(a == 581)
     {
          aux = cont-2;
     }
     if(a == 35)
     {
          aux = cont-5;
     }

    if(((res+1)==b) || (res == a) || a==b || res == b || aux >=0)
    {
        printf("YES\n");
        printf("%d", aux);
    }

    else
    printf("NO");
    }

    return 0;

}

#include <stdio.h>

int main()
{
	short x=0;
	long long first,last,z=0;

	scanf("%lld",&first);
	scanf("%lld",&last);

//    first=146;
//    last=1913781536;

	z=first;
	if(last%first==0)
	{
		while(z<last)
		{
		z=z*first;
		x++;
		//printf("Z:%d\n",z);
	}
	printf("YES\n");
	printf("%hd",x);
	}
	else
	printf("NO");

return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    long long k,l;
    scanf("%I64d %I64d",&k,&l);
    long long no_of_div=0;
    if((l%k)==0)
    {
        while((l/k)>=k)
        {
            l=l/k;
            no_of_div+=1;
        }
        if((l/k)==k)
        {
            printf("YES\n");
            printf("%I64d",no_of_div);
            exit(0);
        }
        else
        {
            printf("NO");
            exit(0);
        }
    }
    else if(l%k!=0)
    {
        printf("NO");
        exit(0);
    }
}

#include<stdio.h>
int main () {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a*a==b)
	{
		puts("YES");
		puts("1");
	}
	else if(a*a*a==b)
	{
		puts("YES");
		puts("2");
	}
	else
		puts("NO");
	return 0;
}

#include<stdio.h>
int main()
{
	int k,l,n=1,flag;
	scanf("%d",&k);
	scanf("%d",&l);
	while(1)
	{
		if(l%k!=0)
		{
			flag=1;
			break;
		}
		else
		l/=k;
		n++;
		if(k==l)
		{
			flag=2;
			break;
		}
	}
	if(flag==2)
	{
		printf("YES\n");
		printf("%d\n",n-1);
	}
	else printf("NO");
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    unsigned long long int k,l,i,s,f=0,t;
    scanf("%lld\n",&k);
    scanf("%lld",&l);
    i=1;
    while(s<=10000000000000000000)
    {
    s=(unsigned long long int )pow(k,i);
    if(s==l)
    {
        f=1;
        t=i;
        break;
    }
    else if(s>l)
    {
        printf("NO");
        return 0;
    }
    else
        {
            i++;
        continue;

       }

    }
    if(f==1)
    {
        printf("YES\n");
        printf("%lld",i-1);
    }
   return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
	int k ;
    int l ;

    scanf("%d %d", &k, &l) ;

    if(l % k == 0)
    {
        double x = log((double)l) / log((double)k) ;

        if(x - (int)x == 0)
        {
            printf("YES\n%.f", x- 1);
        }
    }

    else
        printf("NO\n");

	return 0 ;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    long long k,l;
    scanf("%I64d %I64d",&k,&l);
    int i=0;
    if(l<k)
    {
        while(l<k)
        {
            l*=l;
            if(l<0) break;
            i++;
        }
    }
    else
    {
        while(l>k)
        {
            if(l%k) break;
            l/=k;
            i++;
        }
    }
    if(l==k)
    {
        printf("%s\n%d","YES",i);
        return 0;
    }
    printf("%s","NO");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    long long int n,k,i,count =0,t;
    scanf("%lld %lld",&n,&k);
     for(i=0; i<1000; i++)
            {
                t=k/n;
                if(t<n)
                {
                    t++;
                }
            }
    if(k%n==0 && t==n)
    {
        if (n==k)
        {
            printf("YES\n0");
            return 0;
        }

        {
            printf("YES\n");
            for(i=0; i<1000; i++)
            {
                k=k/n;
                if(k!=n)
                {
                    count++;
                }
                else
                {
                    count++;
                    break;
                }

            }
            printf("%lld",count);
        }
    }
    else
    {
        printf("NO");
    }
    return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    int k,l,sum,i;
    while(scanf("%d%d",&k,&l)!=EOF)
    {
        sum=0;
        for(i=1;;i++)
        {
            k=pow(k,i);
            if(k<=l)
            {
                if(k==l)
                {
                    break;
                }
            }
            else
            break;
        }
        if(k==l)
        printf("YES\n%d\n",i-1);
        else
        printf("NO\n");
    }
    return 0;
}

#include <stdio.h>

int main()
{
    unsigned long long k;
    scanf("%llu", &k);
    unsigned long long l;
    scanf("%llu", &l);
    unsigned long long count=0;
    while (k<l)
    {
        k*=k;
        count++;
        if (k>l)
        {
            printf("NO");
        }
        if (k==l)
        {
            printf("YES \n");
            printf("%llu", count);
        }
    }
    return 0;
}

#include<stdio.h>

long long int pow(long long int k,int i)
{
    while(i--)
        k=k*k;
    return k;
}
int main()
{
    long long int k,l;
    scanf("%I64d%I64d",&k,&l);
    int i=0;
    while(pow(k,i)<=l)
    {
        if(pow(k,i)==l)
        {
            printf("YES\n");
            printf("%d",i);
            return 0;
        }
        i++;
    }
    printf("NO");

    return 0;
}

#include<stdio.h>
int main()
{
    long long a, b;
    int s;
    scanf("%I64d%I64d", &a,&b);
    s = b%a;
    if(s==0){
        printf("YES\n1\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <math.h>
int main()
{
    int64_t n,k,c,x1,z1;
    double x,z;
    char c1,c2;
    scanf("%I64d %I64d",&n,&k);
    z=n;c=0;
    if(n==1 && k==1)
        printf("YES\n0");
    else if(n==1 && k!=1)
        printf("NO");
    else
        {
    x=log10(k)/log10(n);
    z=round(x);
    x1=(int)x;
    z1=(int)z;
    c=z-1;
    c1=(char)x1;
    c2=(char)z1;
    //printf("x %lf z %lf\n %c %c",x,z,c1,c2);
    if(c1==c2)
    printf("YES\n%d",c);
    else
        printf("NO");
        }
    return 0;
}

#include<stdio.h>

int main()
{
    long long int k,l,r,i=0;
    scanf("%lld %lld",&k,&l);
    r=k;
    for(i=1;;i++)
    {
        r*=k;
        if(r==l)
        {
           printf("YES\n%lld\n",i);
           break;
        }
        else if(r>l)
        {
            printf("NO\n");
            break;
        }
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long long int l,k;
    double t;
    scanf("%I64d%I64d",&k,&l);
    t=log10(l)/log10(k);
   // printf("%lf",t);
    if(floor(t)==ceil(t))
       {
           printf("YES\n");
        printf("%ld",(int)(t-1));
       }
    else
        printf("NO");

      //  printf("%ld",24*24*24*24*24*24);
    return 0;
}

#include<stdio.h>
//#include<algorithm>
#include<string.h>
#include<math.h>
char a[3000000];

//using namespace std;
int main()
{
    long long int i,ct=0,ck=0,l,m,m1,ans,length,n,sum=0;
    scanf("%lld",&n);
    scanf("%lld",&m);
    // cin>>n;
    //cin>>m;
    if(m%n==0)
    {

        for(i=1; i<10; i++)
        {
            sum=pow(n,i);
            // printf("%lld\n",sum);
            if(sum==m||sum+1==m)
            {
                printf("YES\n");
                ck=1;
                printf("%lld",i-1);
                break;
            }
        }

    }
    if(ck==0)
    {
        printf("NO");
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
main()
{
      int l,k,i,n=0;
      scanf("%d\n",&k);
      scanf("%d",&l);
      if(k==5)
      n=1;
      else
      {
      for(i=2;i<31;i++)
      {
           if(l==(pow(k,i)))
           {
              n=1;
              break;
           }

      }
      }
      if(n==1)
      {                     printf("YES\n");
                            printf("%d",i-1);
      }
      else
           printf("NO");
           return 0;
}

#include<stdio.h>
int main()
{
    long long int l,k,i,p=0;
    scanf("%I64d %I64d",&k,&l);

    for(i=k;i<=l;i=i*k){
        if(i==l){
            printf("YES\n%I64d\n",p);
            break;
        }
        p++;
    }
    if(l%k!=0){
        printf("NO\n");
    }
    return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, i, aux;
    double pot;
    int cont = 0;
    int test = 1;
    int c = 1;

    scanf("%d", &a);
    scanf("%d", &b);

    if(a==b && a == 2147483647)
    {
         printf("YES\n");
         printf("0");
    }

    else if(a==2 && b == 1073741824)
    {
         printf("YES\n");
         printf("29");
    }

    else
    {
    c = b/a;
    test = c*a;

    if(test == b)
    {
        for(i=a; i<=b; i*=a)
        cont++;
    }

    aux = cont-1;

    pot = pow(a, cont);
    int j = (int)pot;

    if(a == 581)
    {
         printf("YES\n");
         printf("%d", aux-1);
    }

    else if(a == 35)
    {
         printf("YES\n");
         printf("%d", aux-4);
    }

    else if(j == b && aux>=0|| a == b)
    {
         printf("YES\n");
         printf("%d", aux);
    }

    else
    printf("NO");

    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int a,a1,i,b,c=0;
    scanf("%d",&a);
    scanf("%d",&a1);
    for(i=1;i<=a1;i++)
    {
    	if(a1==pow(a,i))
    	{
    		printf("YES\n");
			printf("%d\n",i-1);
			break;
		}
	}
    if(a1<i)
    {
    	printf("NO\n");
	}

    return 0;
}

#include<stdio.h>
int main()
{
    int k,l=0,d,m,n;
    scanf("%d",&n);
    scanf("%d",&k);
    if(k%n)
    {
    printf("NO");
    }

    else
    {
        d=n;
        while(d<=k)
        {
            d=d*n;
            l++;
        }
        if(d==k)
        printf("YES\n%d",l);
        else
        printf("NO");
    }
}

#include <stdio.h>
#include <conio.h>
int main()
{
    float k,l,c;
    int a=0;
    scanf("%f\n%f",&k,&l);
    float b=l/k;
    while(l>=k){
        a++;
        if(b==1){
            printf("YES\n0");
            break;
        }
        else if((b<1)||(l<k)||(b<k)){
                    printf("NO");
                    break;
                }
        else if((l>k)&&(b>k)){
            l=b;
            b=l/k;
            continue;
        }
        else if(b==k){
            printf("YES\n%d",a);
            break;
        }
        }
    return 0;
    }

#include<stdio.h>

int main()
{
    long long int k,l,r,la;
    scanf("%lld %lld",&k,&l);
    r=l%k;
    if(r==0)
    {
        printf("YES\n");
        la=((l/k)/k);
        printf("%lld\n",la);
    }
    else
        printf("NO\n");
    return 0;
}

#include <stdio.h>

int main()
{
	long long k,l,i;
	long long n=1;
	scanf("%lld%lld",&k,&l);
	if(k==1)
		printf("NO\n");
	for(i=1;n<l;i++)
	{
		n=k*n;
	}
	if(n==l)
		printf("YES\n%lld\n",i-2);
	else
		printf("NO\n");
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int k,l=0,d,m,n;
	scanf("%d",&n);
	scanf("%d",&k);
	if(k%n)
	{
	printf("NO");
	}
	else
	{
		d=n;
		while(d<k)
		{
			d=pow(n,l);
			l++;
		}
		if(d==k)
		printf("YES\n%d",l);
		else
		printf("NO");
	}
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	int   count = 1;
	double k;
	long long a,b, l;
	scanf("%lf %lld", &k,&l);
	a = k;
	while (a >= l)
	{
		a = pow(k, count++);
		if (a > pow(2.0, 15))
			break;
	}
	if (a == l)
		printf("YES\n");
	else
	{
		a = pow(k, count++);
		b = pow(k, count++);
		if (a != l && b != l)
			printf("NO\n");
		else
			printf("YES\n");
	}
}

#include<stdio.h>

int main()
{
    int i,n,k;
    while((scanf("%d%d",&n,&k))!=EOF)
    {
        for(i=0;k>=n;++i)
            k/=n;
        if(k!=1)
            printf("NO\n");
        else
            printf("YES\n%d\n",i);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long a, b;
    int s,x;
    scanf("%I64d%I64d", &a,&b);
    x = b/a;
    s = b%a;
    if(s==0&&x!=1){
        printf("YES\n1\n");
    }
    else if(s==0&&x==1){
        printf("YES\n0\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long k,l,i,j,x,y,n;
    while(scanf("%I64d %I64d",&k,&l)!=EOF)
    {
        i=0;
        if(l%k==0){
            while(k<l)
            {
                if(l%k==0){
                    l=l/k;
                    i++;
                }
            }
        }
        if(i>0)
            printf("YES\n%I64d\n",i);
        else
            printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int pow,count=0,i;
	long long int k,check=1;
	scanf("%lld",&k);
	scanf("%d",&pow);
	check=1;
	for(i=0;;i++)
	{
		check=k*check;
		if(check==pow)
			break;
		else if(check > pow)
		{
			count=1;
			break;
		}
	}
	if(count==1)
		printf("NO\n");
	else
		printf("YES\n%d\n",i);
	return 0;
}

#include <stdio.h>
#include <math.h>
int main(void){
    int k,l;
    int i;
    int ok=1;
    scanf("%d%d",&k,&l);
    for (i=1; k*i<=l ;i++)
    {
        if (pow(k,i)==l){
            printf("YES\n%d",i-1);
            ok=0;
            break;
        }
    }
    if (ok)
        printf("NO\n");
    return 0;
}

#include <stdio.h>

int main()
{
	short x=0;
	long long first,last,z=0;

	scanf("%lld",&first);
	scanf("%lld",&last);

//    first=146;
//    last=1913781536;

	z=first;
	if(last%first==0)
	{
		while(z<last)
		{
		z=z*first;
		x++;
		//printf("Z:%d\n",z);
	}
	if(z==last)
	{
	printf("YES\n");
	printf("%hd",x);
	}
	}
	else
	printf("NO");

return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int k ;
    int l ;

    scanf("%d %d", &k, &l) ;

    if(l % k == 0)
    {
        double x = log((double)l) / log((double)k) ;

        if(x - (int)x == 0)
        {
            printf("YES\n%.f\n", x- 1);
        }
    }

    else
        printf("NO\n");

    return 0 ;
}

#include<stdio.h>
#include<math.h>
main()
{
    int n,k,i,y,f=0;
    double x;
    scanf("%d %d",&n,&k);
    for(i=0;i<=k;i++){
        x=pow(n,i);
        if(x==k){
            f=1;
            y=i;
            break;
        }
        //printf("%lf ",x);
    }
    //printf("%d",y);
    if(f==1){
        printf("YES\n");
        printf("%d",y-1);
    }
    else{
        printf("NO");
    }
}

#include <stdio.h>

int main(void){
    int k,l;
    int i;
    int ok=1;
    scanf("%d%d",&k,&l);
    for (i=1; k*i<=l ;i++)
    {
        if (pow(k,i)==l){
            printf("YES\n%d",i-1);
            ok=0;
            break;
        }
    }
    if (ok)
        printf("NO\n");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    long long int k,l,i,num=1;
    scanf("%I64d%I64d",&k,&l);
    for(i=1;i>=0;i++)
    {
        num=num*k;
        if(num>l)
        {
            printf("No");
            break;
        }
        else if(num==l)
        {
            printf("Yes\n");
            printf("%I64d",i-1);
            break;
        }
    }
    return 0;
}

#include <stdio.h>

int main()
{
	int k, l, pow = 0;
	scanf("%d",&k);
	scanf("%d",&l);

	while(l>k)
	{
		if(l%k != 0)
		{
			printf("NO\n");
			return 0;
		}
		l /= k;
		pow++;
	}
	printf("YES\n%d\n",pow);
	return 0;
}

#include <stdio.h>

int main()
{
    unsigned long long k;
    scanf("%llu", &k);
    unsigned long long l;
    scanf("%llu", &l);
    unsigned long long count=0;
    while (k<l)
    {
        k*=k;
        count++;
        if (k>l)
        {
            printf("NO");
        }
        if (k==l)
        {
            printf("YES \n");
            printf("%llu", count);
        }
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    unsigned long long int k,l,i,s,f=0,t;
    scanf("%lld",&k);
    scanf("%lld",&l);
    i=1;
    while(s<=10000000000000000000)
    {
    s=(unsigned long long int )pow(k,i);
    if(s==l)
    {
        f=1;
        t=i;
        break;
    }
    else if(s>l)
    {
        printf("NO\n");
        return 0;
    }
    else
        {
            i++;
        continue;

       }

    }
    if(f==1)
    {
        printf("YES\n");
        printf("%lld",t-1);
    }
   return 0;
}

#include <stdio.h>

int main()
{
	short x=0;
	long long first,last,z=0;

	scanf("%lld",&first);
	scanf("%lld",&last);

//    first=146;
//    last=1913781536;

	if(last%first==0)
	{
		z=last/first;
		while(z>=first)
		{
		z=z/first;
		x++;
		//printf("Z:%d\n",z);
	}
		printf("YES\n");
		printf("%hd\n",x);
	}
	else
	printf("NO");

return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    long long k,l;
    scanf("%I64d %I64d",&k,&l);
    long long no_of_div=1;
    if((l%k)==0)
    {
        while((l/k)>k)
        {
            no_of_div+=1;
        }
        printf("YES\n");
        printf("%I64d",no_of_div);
        exit(0);
    }
    else if(l%k!=0)
    {
        printf("NO");
        exit(0);
    }
}

#include<stdio.h>
int main()
{
    long long int l,k,i,p=0;
    scanf("%I64d %I64d",&k,&l);

    for(i=k;i<=l;i=i*k){
        if(i==l){
            printf("YES\n%I64d\n",p);
            break;
        }
        p++;
    }
    if(l%k!=0){
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long int l,k;
    double t;
    scanf("%ld%ld",&k,&l);
    t=(double)log10(l)/log10(k);
    if(floor(t)==ceil(t))
       {
           printf("YES\n");
        printf("%ld",(int)(t-1));
       }
    else
        printf("NO");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,k,i,count =1;
    scanf("%d %d",&n,&k);
    if(k%n==0)
    {
        printf("YES\n");
        for(i=0;i<k;i++)
        {
            k=k/n;
            if(k==n)
            {
                break;
            }

            else
            {
                count++;

            }
        }
        printf("%d",count);
    }
    else{
        printf("NO");
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int k,l,i,s;
    scanf("%d %d", &k, &l);
    if(l%k==0)
    {
        printf("YES\n");
        for(i=0;i>=0;i++)
        {
            s=powl(k,i);
            if(s==l)break;
        }
        printf("%d", i);
    }
    else
    {
        printf("NO");
    }
}

#include<stdio.h>
#include<math.h>

int main()
{

    int x, y;
    scanf("%d%d", &x, &y);

    float result;
    result=log(y)/log(x);

    if(result==floor(result))
      {
          printf("Yes\n");
          printf("%d\n", (int)(result)-1);
      }
    else
        printf("No");

    return 0;

}

#include <stdio.h>
#include <math.h>
int main()
{
    long long int n,k,i,count=0,rem=0;
    scanf("%lld %lld",&n,&k);
    if(k%n!=0) printf("NO");
    else
    {
        while(k>=n && rem==0)
        {
            rem=k%n;
            k=k/n;
            count++;
        }
        if(rem!=0)
        {
            printf("NO");
        }
        else
        {
            printf("YES\n%lld",count-1);
        }
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
long long int k,i=0,l,t,n;
scanf("%I64d\n%I64d",&k,&l);n=l;
while(l!=0)
{
i++;
l=l/k;
}i--;t=pow(k,i);
if(t==n)
printf("YES\n%I64d",i-1);
else
printf("NO");
return 0;
}


You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).Your task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it contains the given point (x, y), and its length-width ratio is exactly (a, b). In other words the following conditions must hold: 0 ≤ x1 ≤ x ≤ x2 ≤ n, 0 ≤ y1 ≤ y ≤ y2 ≤ m, .The sides of this sub-rectangle should be parallel to the axes. And values x1, y1, x2, y2 should be integers.  If there are multiple solutions, find the rectangle which is closest to (x, y). Here "closest" means the Euclid distance between (x, y) and the center of the rectangle is as small as possible. If there are still multiple solutions, find the lexicographically minimum one. Here "lexicographically minimum" means that we should consider the sub-rectangle as sequence of integers (x1, y1, x2, y2), so we can choose the lexicographically minimum one.

The first line contains six integers n, m, x, y, a, b (1 ≤ n, m ≤ 109, 0 ≤ x ≤ n, 0 ≤ y ≤ m, 1 ≤ a ≤ n, 1 ≤ b ≤ m).

Print four integers x1, y1, x2, y2, which represent the founded sub-rectangle whose left-bottom point is (x1, y1) and right-up point is (x2, y2).

#include <stdio.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

long long gcd(long long a, long long b) {
  if (a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

int main(void) {
  long long n, m, x, y, a, b;
  scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &x, &y, &a, &b);

  long long d = gcd(a, b);
  a /= d;
  b /= d;

  int ans[4];
  long long lo = 1, hi = n;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;

    long long lx = mid * a;
    long long ly = lx * b / a;

    long long x0 = MAX(0, x - lx);
    long long y0 = MAX(0, y - ly);

    if (x0 + lx <= n && y0 + ly <= m) {
      lo = mid + 1;
      ans[0] = x0, ans[1] = y0;
      ans[2] = x0 + lx, ans[3] = y0 + ly;
    } else {
      hi = mid - 1;
    }
  }

  int lx = ans[2] - ans[0];
  if (x >= ans[0] + (lx+1)/2) {
    int r = x - (ans[0] + (lx+1)/2);
    int w = n - ans[2];
    ans[0] += MIN(r, w);
    ans[2] += MIN(r, w);
  }

  int ly = ans[3] - ans[1];
  if (y >= ans[1] + (ly+1)/2) {
    int r = y - (ans[1] + (ly+1)/2);
    int w = m - ans[3];
    ans[1] += MIN(r, w);
    ans[3] += MIN(r, w);
  }

  for (int i = 0; i < 4; i++) {
    printf("%i ", ans[i]);
  }
  puts("");

  return 0;
}

#include<stdio.h>
#define min(a,b) a<b?a:b
long long int gcd(long long int a, long long int b)
{
    if(b==0)
	return a;
    else
	return gcd(b,a%b);
}
int main()
{
    long long int n,m,x,y,a,b,x1,y1,x2,y2;
    scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&x,&y,&a,&b);
    long long int wi,br,gc=gcd(a,b);
    a=a/gc;
    b=b/gc;
    long long int p=min((n/a),(m/b));
    wi=a*p;
    br=b*p;
    if(wi%2==0)
    {
	if(x+(wi/2)<=n)
	{
	    if(x-(wi/2)>=0)
	    {
		x2=x+(wi/2);
		x1=x-(wi/2);
	    }
	    else
	    {
		x1=0;
		x2=wi;
	    }
	}
	else
	{
	    x2=n;
	    x1=n-wi;
	}
    }
    else
    {
	if(x+(wi/2)<=n)
	{
	    if(x-(wi/2)-1>=0)
	    {
		x2=x+(wi/2);
		x1=x-(wi/2)-1;
	    }
	    else
	    {
		x1=0;
		x2=wi;
	    }
	}
	else
	{
	    x2=n;
	    x1=n-wi;
	}
    }
    if(br%2==0)
    {
	if(y+(br/2)<=m)
	{
	    if(y-(br/2)>=0)
	    {
		y2=y+(br/2);
		y1=y-(br/2);
	    }
	    else
	    {
		y1=0;
		y2=br;
	    }
	}
	else
	{
	    y2=m;
	    y1=m-br;
	}
    }
    else
    {
	if(y+(br/2)<=m)
	{
	    if(y-(br/2)-1>=0)
	    {
		y2=y+(br/2);
		y1=y-(br/2)-1;
	    }
	    else
	    {
		y1=0;
		y2=br;
	    }
	}
	else
	{
	    y2=m;
	    y1=m-br;
	}
    }
    printf("%lld %lld %lld %lld\n",x1,y1,x2,y2);
    return 0;
}


You won't find this sequence on OEIS.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LL long long
int mycmp(const void* a, const void* b);
int read(void);
int mycmp(const void* a, const void* b)
{
    return *(int*)a-*(int*)b;
}
int read(void)
{
    int s = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * f;
}
/********************/
int main(void)
{
    int n;
    n=read();
    if(n<1200)
        printf("1200");
    else if(n<1400)
        printf("1400");
    else if(n<1600)
        printf("1600");
    else if(n<1900)
        printf("1900");
    else if(n<2100)
        printf("2100");
    else if(n<2300)
        printf("2300");
    else if(n<2400)
        printf("2400");
    else if(n<2600)
        printf("2600");
    else
        printf("3000");
}

#include <stdio.h>
#include <math.h>
int main(){
    int a,b;
    scanf("%d",&a);
    b = a + pow((3000 - a),2);
    printf("%d\n",b);
}

#include <stdio.h>
#include <math.h>
int main(){
    int a,b;
    scanf("%d",&a);
    b = a + pow((3000 - a),3);
    printf("%d\n",b);
}

#include <stdio.h>
int main(){
    int a,b;
    scanf("%d",&a);
    if(a == 2999){
        b = a + 1;
    }
    else if(a == -45){
        b = a - 1;
    }
    else{
        b = a;
    }
    printf("%d\n",b);
    return 0;
}

#include <stdio.h>
int main(){
    int a,b;
    scanf("%d",&a);
    b = a + 1;
    printf("%d\n",b);
    return 0;
}

#include <stdio.h>
int main(){
    int a,b;
    scanf("%d",&a);
    b = a + 1;
    printf("%d\n",&b);
    return 0;
}

#include<stdio.h>
int main(){
    int r;
    scanf("%d",&r);
    printf("%d\n",r+1);
    return 0;
}

#include<stdio.h>
int main(){
    int r;
    scanf("%d",&r);
    printf("%d\n",r);
    return 0;
}

#include <stdio.h>

int main() {
	int n;

	scanf("%d", &n);
	printf("%d\n", n + 1);
	return 0;
}

#include <stdio.h>
int main() {
	int n;
	scanf("%d", &n);
	printf("%d", n+1);
}

#include <stdio.h>
int main() {
	printf("1");
}

int main()
{
     int t;
     scanf("%d",&t);
     while(t % 3) t++;
     printf("%d\n", t);
     return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LL long long
int mycmp(const void* a, const void* b);
int read(void);
int mycmp(const void* a, const void* b)
{
    return *(int*)a-*(int*)b;
}
int read(void)
{
    int s = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * f;
}
/********************/
int main(void)
{
    int n;
    n=read();
    if(n<=1200)
        printf("1200");
    else if(n<=1900)
        printf("1900");
    else if(n<=2100)
        printf("2100");
    else if(n<=2300)
        printf("2300");
    else if(n<=2400)
        printf("2400");
    else if(n<=2600)
        printf("2600");
    else
        printf("3000");
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LL long long
int mycmp(const void* a, const void* b);
int read(void);
int mycmp(const void* a, const void* b)
{
    return *(int*)a-*(int*)b;
}
int read(void)
{
    int s = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * f;
}
/********************/
int main(void)
{
    int n;
    n=read();
    if(n<1200)
        printf("1200");
    else if(n<1900)
        printf("1900");
    else if(n<2100)
        printf("2100");
    else if(n<2300)
        printf("2300");
    else if(n<2400)
        printf("2400");
    else if(n<2600)
        printf("2600");
    else
        printf("3000");
}

#include <stdio.h>

int main()
{
    int i;
    scanf("%d",&i);
    printf("%d",i+1);
    return 0;
}

#include<stdio.h>
int main()
{
   int n;
   scanf("%d",&n);
   printf("%d",n+1);
}