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.

program pr1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const nn=1024;eps=0.5; nnn=511;  nnnn=9;
label 1;
var s,p1,p2,imin,mmin,pp,p,tt,t,t1,imax,n,k,m,n1,k1,ot,a,b,c,d,k2,j0,ii,jj:int64;
  flag,flag1:boolean;  pl:longint;
  dl,i,j,step:longint;
  ss:string;
 ott:array [0..10000] of int64 ;
 sp,nar :array[0..nn] of string;
 px,x,y:double;
 aa:array[0..nnn,0..20] of int64;
ch1,ch2,ch, chis:array[-10..10000] of int64;
 new1,new2, ss1,ss2:string;
  fl:array[0..nn] of boolean;

  function min(a,b:int64):int64;
begin min:=a;if b<a then min:=b; end;

function max(a,b:int64):int64;
begin max:=a;if b>a then max:=b; end;

 begin
{assign(input,'input.txt');reset(input);
assign(output,'output1234.txt');rewrite(output);  }
read(x,y);

k:=round(ln(y)/ln(x));
px:=1;
for i:=1 to k do px:=px*x;
if px=y then begin writeln('YES'); writeln(k-1);end else writeln('NO') ;

  close (output);
end.

var k,l,p:integer;
begin
     readln(k,l);
     if l mod k<>0 then begin writeln('NO'); exit; end else
     while (l<>1) and (l<>0) do
     begin
          if (l=0) or (l mod k<>0) then begin writeln('NO'); exit; end;
          l:=l div k;
          inc(p);
          if l=1 then begin writeln('YES'); writeln(p-1); exit; end;
     end;
     if l=0 then begin writeln('NO'); exit; end;
     if l=1 then begin writeln('YES'); writeln(p-1); exit; end;
end.

uses
  SysUtils;

var k,l,count:integer;
begin
readln(k);
readln(l);
count:=0;
while l mod k=0 do begin l:=l div k;inc(count);end;
if l=1  then begin writeln('YES');writeln(count-1);end else writeln('NO');
 end.

program project1;

var
 m,mw,n,d:int64;
 k:integer;
 w:integer;

begin
 readln(mw);
 readln(n);
 k:=5;
 d:=0;
 m:=mw;
 while k <>0 do begin
   if n = m then begin
     k:=0;
     w:=4;//YES
    end else begin
     m:=m*mw;
     d:=d+1;
    end;
    if m > n then begin
      k:=0;
      w:=5;//NO
     end;

  end;
 if w = 4 then begin
  writeln('YES');
  write(d);
 end else begin
  writeln('NO');
 end;

 readln;

end.

program Project1_1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  k,l,ans:integer;

begin

{eba one love}
  ans:=0;
  //assign (input, 'input.txt');
  //assign (output, 'output.txt');
  //reset (input);
  read (k,l);
  //close (input);
  //rewrite (output);
  while (l mod k = 0) do
  begin
    if (l=k) then
    begin
      writeln ('YES');
      write (ans);
      //close (output);
      halt (0);
    end
    else
    begin
      l:=l div k;
      inc (ans);
    end;
  end;
  writeln ('NO');
  //close (output);
end.

var
    i,n,s,ansi:longint;
    lol:qword;
    ss:string;
    ok:boolean;
 begin
  read(n,s);
  ok:=false;
  i:=2;
  lol:=n;
  ansi:=0;
  for i:=2 to 100 do
   begin
    if lol=s then begin ansi:=i-2; ss:='YES'; break end
    else if lol>s then begin ss:='NO'; break; end
    else lol:=lol*n;
   end;
  if length(ss)=3 then
   begin
     writeln(ss);
     write(ansi);
   end
     else
       writeln(ss);
 end.

label 1,2,3;
var
 i,n,m,t,k,l:longint;
 s:int64;
begin
  readln(k);
  readln(l);
  if l mod k<>0 then goto 3;
  s:=k;
  1:
  if s=l then goto 2;
  if s>l then goto 3;
  s:=s*k;inc(i);
  goto 1;
  2:writeln('YES');writeln(i);exit;
  3:writeln('NO');
end.

Program cifera;
var k,l,count:longint;
begin
  Readln(k); Readln(l);
    while(l mod k=0) do begin
      l:=l div k;
      Inc(count);
    End;
    If(count=0)or(l<>1) then Writeln('NO')
    Else begin
      Writeln('YES') ;
      Writeln(count-1);
    End;
End.

program Project1;

{$APPTYPE CONSOLE}

var k, l, t: longint;

begin
      read(k, l);
      t := 0;
      while (l >= k) and (l mod k = 0) do
      begin
           l := l div k;
           inc(t);
      end;
      if l = 1 then
      begin
           writeln('YES');
           write(t - 1);
      end
      else writeln('NO');
end.

Var i:longint;
    n,k,s:int64;
   begin
     read(n);
     read(k);
     s:=1;
     for i:=1 to 10000 do
       begin
         s:=s*n;
         if s=k then begin writeln('YES'); writeln(i-1); halt; end;
         if s>k then begin writeln('NO'); halt end;
       end;
   end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k, l, c: integer;

begin
  //reset(input, 'input.txt');
  //rewrite(output, 'input.txt');
  readln(k, l);
  c := 0;
  while (l mod k = 0) and (l > 1) do
  begin
    inc(c);
    l := l div k;
  end;
  if (l = 1) then
  begin
    writeln('YES');
    writeln(c - 1);
  end
  else
    writeln('NO');
  //close(input);
  //close(output);
end.

var
	k, l, z: int64;
	u: longint;

begin
	readln(k, l);
	z := k;
	u := 0;
	while k <= l do begin
		if k = l then begin
			writeln('YES');
			write(u);
			exit;
		end;
		k := k * z;
		inc(u);
    	end;
    	write('NO');
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var k,l,n,ans:integer;
begin
read(k,l); ans:=0;
while true do
  begin
  if l mod k=0 then begin inc(ans); l:=l div k; if l=1 then begin writeln('YES'); writeln(ans-1); readln(n); halt; end; end
               else begin write('NO'); readln(n); halt; end;
  end;

end.

var
   n,k,count:int64;
begin
readln(n);
readln(k);
if n = k then begin
   writeln('YES');
   writeln(0);
   exit;
end;
   repeat
   if k mod n = 0 then begin
   k:=k div n;
   inc(count);
   end
   else begin
        writeln('NO');
        Exit;
end;
   until k = 1;
writeln('YES');
writeln(Count-1);
end.

program Cifera;
var k,l,i,c,s:int64;
flag:boolean;

begin
read(k);
read(l);
s:=k;
c:=0;
If s=l then flag:=true;
while (s<l) do begin
  c:=c+1;
  s:=s*k;
  If s=l then flag:=true;
end;
If flag then begin
  writeln('YES');
  write(c);
end else
  write('NO')
;
end.

program cifera;
var
k,f,l,md : int64;

i,n : int64;
la : int64 ;
las : extended;
begin
        readln(k);
        readln(l);
        md:= l mod k;

            la:= 0 ;
            las:=l;
        if md = 0 then
        begin

        while las > 1 do
        begin

                las:= las / k;
                la:= la + 1;
                end;

                if las = 1 then
                    begin
                      writeln('YES');
         writeln(la-1)
         end
                else
                begin
                writeln('NO');

                end;

         end
         else
         writeln('NO');
end.

program ProjectA;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  l: Int64;
  k, x, i: Integer;

begin
  x := 0;
  Readln(k, l);
  for i := 1 to 32 do begin
    if l = 1 then
      Break;
    if l mod k <> 0 then
    begin
      x := 0;
      Break;
    end;
    l := l div k;
    inc(x);
  end;
  if x <> 0 then
  begin
    Writeln('YES');
    Writeln(x - 1);
  end
  else
    Writeln('NO');
  readln;
  readln;
end.

var
  k,l,ans,u : longword;
begin
  readln(k);
  readln(l);
  ans:=0;
  if l=k then begin writeln('YES'); writeln(ans); exit; end;
  while l>k do begin
    inc(ans);
    u:=l mod k;
    if u>0 then break;
    l:=l div k;
    if l=k then begin writeln('YES'); writeln(ans); exit; end;
  end;
  writeln('NO');
end.

Var osn,ch,step:longint;
begin
readln(osn);
readln(ch);
step:=0;
while (ch div osn>=1) and
(ch mod osn=0) do
begin
step:=step+1;
cH:=ch div osn;
end;
if (step=0) or
(ch<>1) then writeln('NO') else begin writeln('YES'); writeln(step-1);
end;
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var k,l,t,i: int64;

begin
  read(k,l);
  i:=0;t:=k;
  while (t<l)do begin
    t:=t*k;
    inc(i);
  end;
  if (t=l)then begin
    writeln('YES');
    writeln(i);
  end else
    writeln('NO');
end.

program cifera;
var k,l,v,n:longint;
    i:longint;

begin
readln(k);
readln(l);
v:=0;
n:=k;
while k<=l div n do
begin
k:=k*n;
inc(v);
end;
if k=l then
begin
writeln('YES');
writeln(v);
end else
writeln('NO');
end.

var
	n, m, l, k  :  int64;
begin
//	reset(input, 'a.in');
//	rewrite(output, 'a.out');
	read(n, m);
	k := n;
	l := 0;

	while (n < m) do begin
		n := n * k;
		inc(l);
	end;

	if (n = m) then begin
		writeln('YES');
		write(l);
	end else
		write('NO');

end.

program cifera;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k , l , i , a , b , j: Integer;
  check: Boolean;

begin
  Readln(k);
  Readln(l);
  b := l;
  i := 0;
  check := True;

  while l > 0 do
    begin
      if (l mod k = 0) then
        begin
          l := l div k;
          Inc(i);
        end
      else
        Break;
    end;

  a := 1;

  for j := 1 to i do
    a := a * k;

  if a = b then
    begin
      Writeln('YES');
      Writeln(i - 1);
    end
  else
    writeln('NO');

end.

var a,b,c,d,n,k,i,l:int64;
begin

readln(k);
readln(l);

d:=k;
i:=0;

while d*k<=l do
begin
d:=d*k;
i:=i+1;
end;

if d=l then begin writeln('YES'); writeln(i); end else writeln('NO');

end.

 var n,m,a,x,y:int64;
  begin
   read(n,m);
   a:=n;
   if n=m then begin Writeln('YES'); Write(0); end
    else
     begin
     while x<>1 do
      begin
      inc(y);
       n:=n*a;
       if n>m then begin Writeln('NO'); halt;  halt;end;
       if n=m then begin Writeln('YES'); Write(y); halt;end;
      end;
     end;
  end.

{$r-,s-,q-,i-,o+}
var
  k,l,z,m : int64;
begin
  readln(k);
  readln(l);
  z:=k;m:=0;
  while(true)do
    begin
      if(z=l)then begin writeln('YES');writeln(m);halt(0);end;
      if(z>l)then begin writeln('NO');halt(0);end;
      inc(m);z:=int64(k*z);
    end;

end.

var
n,p:longint;
j:int64;
i:integer;
begin
  readln(n);
  readln(p);
     j:=n;
  while p>j do
  begin
     j:=n*j;
     inc(i);
  end;

  if j=p then begin writeln('YES'); write(i) end
  else write('NO');

end.

var k,l:longint;
    ans:longint;
begin
readln(k,l);
ans:=0;
while l<>1 do
  begin
  if l mod k=0 then begin
                    ans:=ans+1;
                    l:=l div k;
                    end
               else begin
                    writeln('NO');
                    break;
                    end;
  end;
if l=1 then begin
            writeln('YES');
            writeln(ans-1);
           end;
end.

var x,y,i,k:int64;
Begin
  readln(x);
  readln(y);
  i:=0;
  k:=x;
  while x<y do
   begin
    x:=x*k;
    inc(i);
   end;
  if x=y then begin writeln('YES');
                    writeln(i);
                    end
                    else writeln('NO');
End.

{$I-,O+,Q-,R-,S-}

var
  k, l, ans: integer;
begin
  readln(k); readln(l);

  repeat
    if l mod k <> 0 then begin write('NO'); exit; end;
    l := l div k;
    inc(ans);
  until l = 1;
  writeln('YES'); write(ans - 1);
end.

program Project1;

{$APPTYPE CONSOLE}
var
   n, l, i, k: int64;
begin
  //reset(input, 'input.txt');
 // rewrite(output, 'output.txt');
  readln(n);
  readln(l);
  k := n;
  i := 0;
  if n > l then
  begin
    writeln('NO');
    exit;
  end;
  if (k = l) then
  begin
    writeln('YES');
    writeln('0');
    exit;
  end;
  while n <= l do
  begin
    n := n * k;
    inc(i);
    if n = l then
    begin
      writeln('YES');
      writeln(i);
      exit;
    end;
  end;
  writeln('NO');
end.

Var k,n,i:longInt;
Begin
  Read(k,n);
  While (n>1)and(n mod k=0) do
    begin
      n:=n div k;
      Inc(i);
    end;
  If n=1 Then begin
   WriteLn('YES');
   WriteLn(i-1);
              end
         else WriteLn('NO');
End.

{$APPTYPE CONSOLE}

var
k,n,st : int64;
i : integer;
begin
readln (k);
readln (n);
i:=0;
st:=k;
while k<n do
begin
k:=k*st;
inc (i);
end;
if k=n then begin writeln ('YES'); write (i); end
else write ('NO');
end.

var
  n,k,i,q : int64;

begin
  readln(n,k);
  q:=n;
  while n <= k do
    begin
      if n = k then begin writeln('YES'); writeln(i); exit; end;
      inc(i);
      n:=n*q;
    end;
  writeln('NO');
end.

var
  k,l:longint;
  n:longint;
  tamp:qword;
 begin
   readln(k);
   readln(l);
   if l mod k<>0 then
   begin
     writeln('NO');
     halt;
   end;
   while l>0 do
   begin
     if (l=1) then
     begin
       writeln('YES');
       writeln(n-1);
       halt;
     end;
     if (l mod k<>0) then
     begin
       writeln('NO');
       halt;
     end;
     inc(n);
     l:=l div k;
   end;
 end.

const fi = '';
        fo = '';
var
        f : text;
        n,m,k,i : int64;
        p : boolean;
begin
        assign(f,fi);
        reset(f);
        readln(f,n);
        readln(f,m);
        Close(f);
        k := 1;
        p := false;
        i := -1;
        repeat
                k := k*n;
                if k = m then p := true;
                inc(i);
        until (p = true) or (k > m);
        Assign(f,fo);
        rewrite(f);
        if p = true then
        Begin
                Writeln(f,'YES');
                Writeln(f,i);
        End
        else writeln(f,'NO');
        Close(f);
End.

var r,k,s,n:longint;
begin
readln(k);
readln(s);
r:=1;
n:=0;
if s>=k then begin
while r<>10 do begin
if s mod k=0 then begin
s:=s div k;
n:=n+1;
end;
if (s>1) and (s mod k>0) then begin
n:=0;
r:=10;
end;
if s=1 then r:=10;
end;
end;
if n-1>=0 then begin
writeln('YES');
writeln(n-1);
end;
if n=0 then writeln('NO');
readln;
end.

var
k,l,i:int64;
begin
readln(k);
readln(l);
while l>0 do
  begin
    if l=1 then
      begin
        writeln('YES');
        writeln(i-1);
        halt;
      end;
    if l mod k<>0 then
      begin
        writeln('NO');
        halt;
      end;
    l:=l div k;
    inc(i);
  end;
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
k,n,o,z:int64;
begin
o:=1;
readln(k,n);
z:=k;
while k<n do begin
inc(o);
k:=k*z;
end;
if k<>n then writeln('NO')
else
begin
writeln('YES');
writeln(o-1);
end;
end.

var
	l,k,count	:longint;
	cek	: integer;
begin
	readln(k);
	readln(l);

	cek:=1;
	while l>1 do
	begin
		if (l mod k) <> 0 then
		cek:=0;
		count:=count+1;
		l:=l div k;
	end;

	if cek=1 then
	begin
		writeln('YES');
		writeln(count-1);
	end else
		writeln('NO');
end.

var
   i,k,l,sum:longint; bo:boolean;

begin
  readln(k);
  readln(l);
  sum:=1;
  if l mod k<>0 then
    begin
      writeln('NO');
      halt;
    end;
  bo:=true;
  while bo do
    begin
      sum:=sum*k;
      if l mod sum<>0 then
        begin
          writeln('NO');
          halt;
        end;
      inc(i);
      if sum=l then
        begin
          writeln('YES');
          writeln(i-1);
          break;
        end;
      if sum>l then
        begin
          writeln('NO');
          break;
        end;
    end;
end.

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
n,k,a,count:int64;
begin
readln(n);
readln(k);
a := n;
while n < k do
begin
n := n * a;
count := count + 1;
end;
if n = k then
begin
writeln('YES');
writeln(count);
end
else
writeln('NO');
end.

var
 n,m,i:longint;
 s:int64;
begin
 readln(n);
 readln(m);
 i:=1; s:=1;
 while s<>m do
  begin
   if s>m then
    begin
     writeln('NO');
     halt;
    end;
   s:=s*n;
   inc(i);
  end;
 writeln('YES');
 writeln(i-2);
end.

uses
  SysUtils;
var
  tmp,k,n,m:Int64;
begin
  readln(n);
  Readln(m);
  k:=n;
  tmp:=0;
  while n<m do begin
    n:=n*k;
    Inc(tmp);
  end;
  if n<>m then write('NO') else begin
    Writeln('YES');
    write(tmp);
  end;
  readln;readln;
end.

var
  k,l,i:int64;
begin
  readln(k);
  read(l);
  while l>0 do
  begin
    if l=1 then begin writeln('YES'); write(i-1); halt; end;
    if l mod k<>0 then begin write('NO'); halt; end;
    l:=l div k;
    inc(i);
  end;
end.

{$APPTYPE CONSOLE}
{$R+,S+,Q+,I+,O-}
{R-,S-,Q-,I-,O+}

uses
	SysUtils, Math;

var
	n, k, ans : longint;
	i : int64;

procedure fuck();
begin
	write('NO');
	halt(0);
end;

begin
{$IFNDEF ONLINE_JUDGE}
	reset(input, 'input.txt');
	rewrite(output, 'output.txt');
{$ENDIF}
	read(k, n);
	if n < k then fuck();
	i := k;
	ans := 0;
	while i < n do begin
		i := i * k;
		inc(ans);
	end;
	if i > n then fuck();
	writeln('YES');
	write(ans);
end.

{$R+ Q+ I+}
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
   k,l:int64;

   i,n,c:integer;
   t:boolean;
begin
   readln(k);
   n:=k;
   read(l);
   t:=true;
   c:=0;
   while k<>l do begin
         k:=k*n;
         inc(c);
         if k>l then begin
            t:=false;
            break;
         end;
   end;
   if t then begin
      writeln('YES');
      write(c);
   end
   else write('NO');
end.

var a,b,c,suma,d,z:int64;
var i,j:longint;

begin

readln (a,b);
      suma:=1;

      if a=b then
         begin
         writeln ('YES');
         writeln (0);
         exit;
         end;

for I:= 1 to 31 do

      begin
        suma:= suma*a;
      if suma=b then

               begin
               writeln('YES');
               writeln(i-1);
               exit;
               end;

          d:=1;
      end;

      writeln ('NO');

      end.

var k, l, i:longint;
    bool:byte;
    x:real;
begin
 readln(k, l);
 x:=l;
 i:=0;
 bool:=0;
 while x>k do
  begin
   if (frac(x/k)=0) then begin
                         i:=i+1;
                         x:=x/k;
                         end
                    else begin
                         bool:=1;
                         break;
                         end;
  end;
  if bool=0 then begin
                 if x=k then begin
                              writeln('YES');
                              write(i)
                             end
                        else write('NO');
                  end
             else write('NO');
end.

var
  a,b,cn:int64;
  f:boolean;
begin
read(a,b);
cn:=0;
f:=true;
while (b>1)do
   begin
   if (b mod a<>0) then
        begin
        write('NO');
        f:=false;
        exit;
        end
   else
   b:=b div a;
   inc(cn);
   end;
if f then begin write('YES'); writeln; write(cn-1); end;
end.

Program cifera;
Var k,l,i:Int64;
Begin
    readln(k);
    readln(l);
    if ((l mod k)=0)
    then begin
           I:=0;
           While l>k do
           begin
               l:=l div k;
               Inc(I);
           end ;
           if l<>k
           then writeln('NO')
           else begin
                writeln('YES');
                writeln(I);
                end;
         end
    else writeln('NO');
End.

var
 k,l,x,n:longint;
 p:boolean;
begin
 readln(k);
 readln(l);
 x:=l;
 p:=true;
 while (x<>1) and p do
  begin
   inc(n);
   if x mod k<>0 then p:=false;
   x:=x div k;
  end;
 if p=false then writeln('NO')
                   else begin writeln('YES'); writeln(n-1); end;
end.

var a,b,ans,cur:int64;

begin

  readln(a);
  readln(b);

  ans:=0;
  cur:=a;

  while true do
    begin
      if cur>=b then break;
      inc(ans);
      cur:=cur*a;
    end;

  if cur<>b then writeln('NO')
    else
      begin
        writeln('YES');
        writeln(ans);
      end;

end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var k,k1,l,n:int64;

begin
readln(k);
k1:=k;
readln(l);
n:=0;
while (k<l) do
begin
k:=k*k1;
inc(n);
end;
if k=l then
begin
  writeln('YES');
  writeln(n);
end
else
  writeln('NO');

  { TODO -oUser -cConsole Main : Insert code here }
end.

Var i:longint;
    s,n,k:int64;
    begin
      read(n);
      read(k);
      s:=1;
      for i:=1 to 1000 do
        begin
          s:=s*n;
          if s=k then begin writeln('YES'); writeln(i-1); halt; end;
          if s>k then begin writeln('NO'); halt; end;
        end;
    end.

var k,i,n,m,p,j:int64;
begin
readln(k);
readln(n);
m:=k;
j:=0;
while n>=k do begin
if k=n then begin
            p:=1;
            n:=0;
            break;
            end;
k:=k*m;
inc(j);
end;
if p=1 then begin
       writeln('YES');
       write(j);
       end;
if p<>1 then write('NO');
end.

//da noi co dong nay roi ma
{$MODE OBJFPC}
var
        k, l : int64; //ok?ok
        res : integer;
begin
        readln (k, l);
        //kt xem l co chia het cho k ko
        if l mod k <> 0 then
        begin
          write('NO');
          exit; //dung de thoat khoi chuong trinh. ok? tiep

        end;
        while l <> k do
        begin
          l := l div k; //moi lan nhu rua l div k. tuc la dec(mu)
          if l = 0 then
          begin
            write('NO');
            exit;
          end;
          //dung de loai truong hop 2 6 do :))
          //han se lap cho den khi l = 1; 1 div 2 = 0
          inc(res);
        end;

        writeln ('YES'); writeln (res);
readln;
end.

ok?
nop bai quai

var
 l,i:longint;
 k,s:int64;
begin
  read(k,l);
  i:=0;s:=k;
  while k<l do
   begin
    k:=k*s;
    inc(i);
   end;
  if k=l then begin
               writeln('YES');
               write(i);
              end
         else write('NO');
end.

uses
  SysUtils;
var
  tmp,k,n,m:Int64;
begin
  readln(n);
  Readln(m);
  k:=n;
  tmp:=0;
  while n<m do begin
    n:=n*k;
    Inc(tmp);
  end;
  if n<>m then write('NO') else begin
    Writeln('YES');
    write(tmp);
  end;
  readln;readln;
end.

uses math;
var l, k: longint;
    e: real;
begin
        readln(k);
        readln(l);
        e := logn(k, l);
        if e = trunc(e) then
        begin
                writeln('YES');
                writeln(trunc(e) - 1);
        end
        else
                writeln('NO');
end.

var
 q,w,l:Int64;
begin
 Read(q,w);
 While (w mod q = 0)and(w<>0) do begin
                   w:=w div q;
                   Inc(l);
                   //Writeln(w);
                      end;
 if w = 1 then begin
               Writeln('YES');
               Write(l-1);  end else Write('NO');

end.

var	i,k,l:longint;
	t:int64;
    	chk:boolean;

begin
	readln(k);
	readln(l);
	i:=1;
    	t:=k;
	while t<=l do
	begin
		if t=l then
       		begin
            			chk:=true;
            			break;
        		end;
		t:=t*k;
		inc(i);
	end;
	if chk=true then
   	begin
        		writeln('YES');
        		write(i-1);
    	end
    	else write('NO');
    	readln;
end.

program aaaaaa;
var i,x,l,k:uint64;

begin
   read(k,x);
   while x>k do
     begin
       if x mod k > 0 then begin writeln('NO'); halt; end;
       x:=x div k;
       i:=i+1;

     end;
   if x=k then begin writeln('YES'); writeln(i); halt; end;
   writeln('NO');

end.

program calendar;
{$APPTYPE CONSOLE}
uses
  SysUtils;

var a,b,c:int64;
begin
read(a,b); c:=0;
while b mod a=0 do begin c:=c+1; b:=b div a; end;
if b<>1 then write('NO')
        else
        begin
        writeln('YES');
        write(c-1);
        end;
end.

var k,l,i:longint;
begin
  readln(k);
  read(l);
  while l>0 do
    begin
      if l=1 then begin writeln('YES'); write(i-1); halt; end;
      if l mod k<>0 then begin write('NO'); halt; end;
      l:=l div k;
      i:=i+1;
    end;
end.

var
 s,n,m:qword;
 i,j:longint;
begin
 readln(n);
 readln(m);
  s:=1;
   for i:=1 to 10000005 do
    begin
     if s=m then begin writeln('YES');writeln(i-2);halt;end
            else if s>m then begin writeln('NO');halt;end;
     s:=s*n;
    end;
end.

program Project;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k,l:int64;
  c:integer;
begin
  read(k,l);
  c:=-1;
  while true do
    begin
      if ( l mod k ) =0 then
        begin
          l:=l div k;
          inc(c);
        end
      else
        begin
          if l=1 then
            begin
              writeln('YES');
              writeln(c);
              break;
            end
          else
            begin
              Writeln('NO');
              break;
            end;
        end;
    end;
  readln;readln;
end.

program cifera;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k, l, st: longint;

begin
 { assign(input, 'input.txt');
  assign(output, 'output.txt');
  reset(input);
  rewrite(output); }

  read(k, l);
  st := 0;
  while (l mod k = 0) do
  begin
    l := l div k;
    inc(st);
  end;
  if l = 1 then
  begin
    writeln('YES');
    writeln(st - 1);
  end
  else
    writeln('NO');

  //close(input);
  //close(output);
end.

var k,l,i,o :int64;
begin
read (k,l);
i:=1;  o:=0;
i:=k;
while i<=l do
begin
if i<l then
   begin
    i:=i*k;
    inc(o);
   end;

if i=l then
   begin
     Writeln ('YES');
     Writeln(o);
     exit;
   end;
end;
Writeln('NO');
end.

var
	n, m, l, k  :  int64;
begin
//	reset(input, 'a.in');
//	rewrite(output, 'a.out');
	read(n, m);
	k := n;
	l := 0;

	while (n < m) do begin
		n := n * k;
		inc(l);
	end;

	if (n = m) then begin
		writeln('YES');
		write(l);
	end else
		write('NO');

end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var k,l,t,i: int64;

begin
  read(k,l);
  i:=0;t:=k;
  while (t<l)do begin
    t:=t*k;
    inc(i);
  end;
  if (t=l)then begin
    writeln('YES');
    writeln(i);
  end else
    writeln('NO');
end.

uses
  SysUtils;

var k,l,count:integer;
begin
readln(k);
readln(l);
count:=0;
while l mod k=0 do begin l:=l div k;inc(count);end;
if l=1  then begin writeln('YES');writeln(count-1);end else writeln('NO');
 end.

var
  k, l, c: int64;
  i : longint;
begin
  {assign(input, 'input.txt');
  assign(output, 'output.txt');
  reset(input);
  rewrite(output);}
  readln(k, l);
  c := 1;
  if k = l then
  begin
    writeln('YES');
    writeln('0');
    exit;
  end;
  for i := 1 to 200000 do
  begin
    c := c * k;
    if c > l then
      break;
    if k * c = l then
    begin
      writeln('YES');
      writeln(i);
      exit;
    end;
  end;
  writeln('NO');
end.

{$R-, S-, Q-}
program task_1;
var
  ans : boolean;
  k, l, r, count : Int64;
begin
  readln(k);
  readln(l);
  count := 0;
  r := k;
  while r < l do
  begin
    r := r * k;
    inc(count);
  end;
  if r=l then
    ans := true;
  if ans then
  begin
    writeln('YES');
    write(count);
  end
  else
    writeln('NO');
end.

Program cifera;
Var k,l,i:Int64;
Begin
    readln(k);
    readln(l);
    if ((l mod k)=0)
    then begin
           I:=0;
           While l>k do
           begin
               l:=l div k;
               Inc(I);
           end ;
           if l<>k
           then writeln('NO')
           else begin
                writeln('YES');
                writeln(I);
                end;
         end
    else writeln('NO');
End.

var       s,i,k,j,n: int64;
begin
   readln(k);
   s:=1;
   readln(n);
   j:=0;
   repeat
      s:=s*k;
      inc(j);
   until s>=n;
 if  s=n then
  begin
    writeln('YES');
    writeln(j-1);
  end
  else  writeln('NO');
end.

var k, l, i:longint;
    bool:byte;
    x:real;
begin
 readln(k, l);
 {i:=0;
 x:=1;
 while x<l do
  begin
  i:=i+1;
  x:=x*k;
  end;
 if x=l then begin
             writeln('YES');
             write(i-1);
             end
        else write('NO'); }

 x:=l;
 i:=0;
 bool:=0;
 while x>k do
  begin
   if (frac(x/k)=0) then begin
                         i:=i+1;
                         x:=x/k;
                         end
                    else begin
                         bool:=1;
                         break;
                         end;
  end;
  if bool=0 then begin
                 if x=k then begin
                              writeln('YES');
                              write(i)
                             end
                        else write('NO');
                  {if (i=0)and(k<>x) then write('NO')
                  else begin
                       writeln('YES');
                       write(i);
                       end;  }
                  end
             else write('NO');
end.

var a,b,c,suma,d,z:int64;
var i,j:longint;

begin

readln (a,b);
      suma:=1;

      if a=b then
         begin
         writeln ('YES');
         writeln (0);
         exit;
         end;

for I:= 1 to 31 do

      begin
        suma:= suma*a;
      if suma=b then

               begin
               writeln('YES');
               writeln(i-1);
               exit;
               end;

          d:=1;
      end;

      writeln ('NO');

      end.

Program Cifera;
var
k,l : int64;
output, temp : int64;
IsPossible : boolean;
begin
readln(k);
readln(l);
output := 0;
 if k <= l then
   begin
   IsPossible := true;
     while k < l do
       begin
          temp := l mod k;
          if temp = 0 then inc(output)
           else IsPossible := false;
          l := l div k;
       end;
       if l <> k then IsPossible := false;
     if IsPossible then
       begin
           writeln('YES');
           writeln(output);
       end else writeln('NO');
   end else writeln('NO');
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a,f,n: int64;
  P,flag:word;

begin
 readln(a); readln(f); p:=0; n:=a; flag:=0;
 while n<=f do
  begin
  if n=f then begin  flag:=1; break;  end;
  n:=n*a; p:=p+1;
  end;

  if flag =1 then begin writeln('YES'); Writeln(p); end
            else writeln('NO');
  Readln;

end.

{APPTYPE CONSOLE}
{$o-}
var k,l,f: int64; i: longint;
begin
//reset(input,'a.in');
//rewrite(output, 'a.out');
readln(k); f:=k;
read(l); i:=0;
while k<l do
begin
k:=f*k;  inc(i);
end;
if k>l then Write('NO') else Write('YES', #13, #10, i);

end.

program a86;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var a,i,k:integer;

begin
  readln(a);
  readln(i);
  k:=0;
  while i mod a = 0 do begin
    i:=i div a;
    k:=k+1;
  end;
  if (k<>0) and (i=1) then begin
    writeln('YES');
    writeln(k-1);
  end else write('NO');
end.

var k,l:longint;
    ans:longint;
begin
readln(k,l);
ans:=0;
while l<>1 do
  begin
  if l mod k=0 then begin
                    ans:=ans+1;
                    l:=l div k;
                    end
               else begin
                    writeln('NO');
                    break;
                    end;
  end;
if l=1 then begin
            writeln('YES');
            writeln(ans-1);
           end;
end.

Var a,t,i,x:Int64;
 begin
  Read(a,x);
  t:=a;
  i:=1;
  While a<x do
   begin
    a:=a*t;
    Inc(i);
   end;
  if a=x then begin WriteLn('YES'); WriteLn(i-1); end
              else WriteLn('NO');

end.

var k,l,i:longint;
begin
  readln(k);
  read(l);
  while l>0 do
    begin
      if l=1 then begin writeln('YES'); write(i-1); halt; end;
      if l mod k<>0 then begin write('NO'); halt; end;
      l:=l div k;
      i:=i+1;
    end;
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var a,b,x:int64;
    i:longint;
begin
  readln(a);
  readln(b);
  x:=a;
  for i:=1 to 10000 do
  begin
    if x>b then
    begin
      writeln('NO');
      break;
    end else
      if x=b then
      begin
        writeln('YES');
        writeln(i-1);
        break;
      end else x:=x*a;
  end;
end.

// luogu-judger-enable-o2
var i,k:longint;
    n,m,n1:qword;
 begin
  readln(n);
  readln(m);
   n1:=n;
   while n<m do
    begin
     n:=n*n1;
     i:=i+1;
     if n=m then begin k:=1;break;end;
    end;
  if k=1 then begin writeln('YES');write(i);end else write('NO');
end.

var k,x,i,l:longint;
begin
readln(k);
readln(x);
i:=0;
if k=x then writeln('NO')
else
begin
l:=k;
while  (k*l)<=x+1 do
begin
k:=k*l;
i:=i+1;
if k=x then begin writeln('YES'); writeln(i); k:=0; break; end;
end;
if k<>0 then writeln('NO');
end;
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a:array[1..1000000] of string;
  k,j,n,i:Integer;
  s:string;
  f:Int64;
function lol(n,f:Integer):Integer;
var
  i,k,j:Integer;
begin
  k:=0;
  j:=n;
  for i:=1 to 100 do
    begin
      if (n=f) then Break;
      n:=n*j;
      inc(k);
    end;
  if (f=n) then lol:=k
    else lol:=0;
end;
begin
  Readln(n);
  Readln(k);
  if (n>k) then
    begin
      if (lol(k,n)>0) then
        begin
          Writeln('YES');
          write(lol(k,n))
        end
          else write('NO')
    end else begin
  if (lol(n,k)>0) then
    begin
      Writeln('YES');
      write(lol(n,k))
    end
    else write('NO');
  end;
  Readln;
  Readln;
end.

var
 i,j,n,m,k,l:qword;
begin
 readln(k);
 readln(l);
 if k=l then begin writeln('NO'); halt ;end;
 while (k<l) do
  begin
   k:=k*k;
   inc(m);
  end;
 if (k=l ) then begin
 writeln('YES');
 writeln(m);
 end
 else writeln('NO');
end.

Var n,k:int64;
    i:longint;
 begin
   Read(k,n);
    if k=n then begin writeln('YES'); writeln(0); exit; end;
   for i:=1 to 100 do
    begin
      k:=k*k;
      if k=n then begin writeln('YES'); writeln(i); exit; end;
      if k>n then begin writeln('NO');exit; end;
    end;

 end.

var k,l,r:longint;
begin
    readln(k,l); r:=0;
    while (l mod k=0) do
    begin
        inc(r); l:=l div k;
    end;
    if (r>0) then
    begin
        writeln('YES'); writeln(r-1);
    end else writeln('NO');
end.

var
  k,l,v,j:int64;
  f:real;
begin
read(k,l);
v:=0;
j:=2;
while (j<=l)do
   begin
 f:=exp(j*ln(k));
 if (f<=l)then              begin
                            inc(v);
                            end;
 inc(j);
   end;
 if v>=1 then begin write('YES'); writeln; write(v); end
 else write('NO');
end.

program zadanie12;
var a,k,l:real;
begin
readln(k);
readln(l);
a:=0;
if k=l then
begin
k:=l;
writeln('YES');
writeln(a);
end;
while l>k do
begin
k:=k*k;
a:=a+1;
if k=l then
begin
k:=l;
writeln('YES');
writeln(a);
end;
end;
if k<>l then writeln('NO');
end.

Var n,k,j:int64;
    i:longint;
 begin
   Read(k,n);
   j:=k;
    if k=n then begin writeln('YES'); writeln(0); exit; end;
   for i:=1 to 100 do
    begin
      j:=j*k;
      writeln(k);
      if j=n then begin writeln('YES'); writeln(i); exit; end;
      if k>n then begin writeln('NO');exit; end;
    end;

 end.

var
  k,l:longint;
  n:longint;
  tamp:qword;
 begin
   readln(k);
   readln(l);
   if l mod k<>0 then
   begin
     writeln('NO');
     halt;
   end;
   while l>0 do
   begin
     if (l=1) then
     begin
       writeln('YES');
       halt;
     end;
     if (l mod k<>0) then
     begin
       writeln('NO');
       halt;
     end;
     inc(n);
     l:=l div k;
   end;
 end.

var i,j,k,l,n,m,p,r,t:longint;

begin

    read(k,l);

    n:=k;
    while (n<l)and(n<>1) do
    n:=n*k;

    if(n=l)and(k<>l) then write('YES')
    else write('NO');

end.

var
	l,k	:longint;
	cek	: integer;
begin
	readln(k);
	readln(l);

	cek:=1;
	while l>1 do
	begin
		if (l mod k) <> 0 then
		cek:=0;
		l:=l div k;
	end;

	if cek=1 then
	begin
		writeln('YES');
	end else
		writeln('NO');
end.

const finp='';
      fout='';
var n,k,dem,LC:longint;
procedure nhap;
var f:text;
begin
     assign(f,finp);
     reset(f);
     readln(f,k,n);
     close(f);
end;
{---------------------}
procedure xuli;
begin
     LC:=0; dem:=0;
     while n>=k do
      begin
       if n mod k=0 then
        begin
         n:=n div k;
         inc(dem);
        end
       else
        begin
         LC:=1;
         break;
        end;
      end;
     if n=1 then
      LC:=1;
end;
{---------------------}
procedure xuat;
var g:text;
begin
     assign(g,fout);
     rewrite(g);
     if LC=0 then
      begin
       writeln(g,'YES');
       write(g,dem);
      end
     else
      writeln(g,'NO');
     close(g);
end;
{---------------------}
begin
     nhap;
     xuli;
     xuat;
end.

var
 i,j,n,m,k,l:int64;
begin
 readln(k,l);
 if k=l then begin
 writeln('YES');
 writeln(0);
 halt;
 end;
 while (k<l) do
  begin
   K:=sqr(k);
   inc(m);
  end;
 if k=l then begin
 writeln('YES');
 writeln(m);
 end
 else writeln('NO');
end.

var a,b,c,d,f,j,k:int64;
s:string;
i,e:longint;
arr:array [1..1000] of longint;
begin
read(a,b);
for i:=1 to (b div a) do begin
if b=a then begin writeln('YES'); write(i-1); halt; end;
a:=a*a;
end;
write('NO');
end.

{$R+ Q+ I+}
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
   t:boolean;
   k,i,n,d,l:integer;
begin
   readln(n);
   read(l);
   k:=0;
   d:=n;
   t:=false;
   for i:=1 to round(sqrt(l)) do begin
       if n=l then begin
          t:=true;
          break;
       end;
       n:=n*d;
       inc(k);
       if n>l then begin
          t:=true;
          break;
       end;
   end;
   if t=true then begin
      writeln('YES');
      write(K);
      end
      else write('NO');
   end.

{$I-,O+,Q-,R-,S-}

var
  k, l, ans: integer;
begin
  readln(k); readln(l);

  repeat
    if l mod k <> 0 then break;
    l := l div k;
    inc(ans);
  until l = 1;
  if ans = 0 then write('NO')
  else begin writeln('YES'); write(ans - 1); end;
end.

var i:integer;
k,x,l:qWord;
begin
i:=0;
readln(x);
readln(l);
k:=x;
while k<l do
begin
k:=k*x;
i:=i+1;
end;
writeln(k);
if k=l then begin writeln('YES'); write(i); end else write('NO');

end.

var a, b : int64;
ans : byte;
begin
ans := 0;
read(a, b);
while b > a do begin
  b := b div a;
  inc(ans);
end;
if b = a then begin
  writeln('YES');
  writeln(ans);
end
  else writeln('NO');
end.

Program p1;
var
k,l,i,a:longint;
label l1;
begin
readln(k);
readln(l);
i:=0;a:=l;
if k>l then writeln('NO') else
begin
l1: if a=1 then
    begin
    writeln('YES');
    writeln(i-1);
    end
  else if a<k then writeln('NO') else
    begin
    a:=a div k;
    inc(i);
    goto l1;
    end;
end;
end.

var r,k,s,n:longint;
begin
readln(k);
readln(s);
r:=1;
if s>k then begin
while r<10 do begin
if s mod k=0 then begin
s:=s div k;
n:=n+1;
end;
if (s>k) and (s mod k>0) then begin
n:=0;
r:=10;
end;
if s=1 then r:=10;
end;
end;
if n-1 > 0 then begin
writeln('YES');
writeln(n-1);
end;
if n-1<=0 then writeln('NO');
readln;
end.

var x,y,i: int64;

begin
  i:=0;
  readln(x,y);
  repeat
  if y mod x <> 0 then
  begin
  writeln('NO');
  exit;
  end
  else
  y:=y div x;
  i:=i+1;
  until y<>x;
  writeln('YES');
  if i = 0 then  writeln('NO') else writeln(i-1);
  end.

var
  k,l:longint;
begin
  readln(k);
  readln(l);
  if trunc(sqrt(l))=sqrt(l) then
    begin
      writeln('YES');
      write(trunc(sqrt(l))-1);
      halt;
    end;
  write('NO');
end.

var a,b,l,n:int64;
begin
 readln(a,b);
 l:=a;n:=1;
 while l<b do
  begin
   l:=l*a;
   inc(n);
  end;
 if l=b then begin writeln('Yes');writeln('1');end
        else writeln('NO');

end.

program Project1;

{$APPTYPE CONSOLE}
var
   n, l, i, k: int64;
begin
  //reset(input, 'input.txt');
 // rewrite(output, 'output.txt');
  readln(n);
  readln(l);
  k := n;
  i := 0;
  if n > l then
  begin
    writeln('NO');
    exit;
  end;
  if (k = l) then
  begin
    writeln('YES');
    writeln('0');
  end;
  while n <= l do
  begin
    n := n * k;
    inc(i);
    if n = l then
    begin
      writeln('YES');
      writeln(i);
      exit;
    end;
  end;
  writeln('NO');
end.

var k,l,r:longint;
begin
    readln(k,l); r:=0;
    while (l mod k=0) do
    begin
        inc(r); l:=l div k;
    end;
    if (r>1) then
    begin
        writeln('YES'); writeln(r-1);
    end else writeln('NO');
end.

var
 t,k,l,i,j:integer;
begin
 readln(k);
 readln(l);
 if (l mod k<>0) or (l<k) then
 begin
  writeln('NO');
  halt;
 end;
 t:=k;
 i:=1;
 while t<l do
 begin
  t:=t*k;
  inc(i);
 end;
 if t<>l then
 begin
  writeln('NO');
  halt;
 end;
 writeln('YES');
 writeln(i-1);
end.

var k, l, i:longint;
    bool:byte;
    x:real;
begin
 readln(k, l);
 {i:=0;
 x:=1;
 while x<l do
  begin
  i:=i+1;
  x:=x*k;
  end;
 if x=l then begin
             writeln('YES');
             write(i-1);
             end
        else write('NO'); }

 x:=l;
 i:=0;
 bool:=0;
 while x>k do
  begin
   if (frac(x/k)=0) then begin
                         i:=i+1;
                         x:=x/k;
                         end
                    else begin
                         bool:=1;
                         break;
                         end;
  end;
  if bool=0 then begin
                  writeln('YES');
                  write(i);
                  end
             else write('NO');
end.

program zadanie12;
var a,k,l:real;
begin
readln(k);
readln(l);
a:=0;
if k=l then
begin
k:=l;
writeln('YES');
writeln(a);
end;
while l>k do
begin
k:=k*k;
a:=a+1;
if k=l then
begin
k:=l;
writeln('YES');
writeln(a);
end;
end;
if k<>l then writeln('NO');
end.

var k,l,p:integer;
begin
     readln(k,l);
     if l mod k<>0 then begin writeln('NO'); exit; end else
     while (l<>1) and (l<>0) do
     begin
          l:=l div k;
          inc(p);
          if l=0 then begin writeln('NO'); exit; end;
          if l=1 then begin writeln('YES'); writeln(p-1); exit; end;
     end;
     if l=0 then begin writeln('NO'); exit; end;
     if l=1 then begin writeln('YES'); writeln(p-1); exit; end;
end.

program FFFF;
{�����}
{$APPTYPE CONSOLE}
uses
  SysUtils,Math;
var n,m,x,y,ans,i,j:integer;

begin
  //reset(input,'input.txt');
  //rewrite(output,'output.txt');
  read(n,m);
  while m>1 do begin
  if m mod n<>0 then begin
        write('NO');
    halt;
  end;
  inc(ans);
  m:=m div n;
  end;
  writeln('YES');
  write(ans-1);

end.

var
 n,z,g,n1:longint;
begin
 readln(n);
 readln(n1);
 g:=0;
 z:=n;
 while (z<=n1) do
 begin
  z:=z*n;
  inc(g);
  if z=n1 then
  begin
   writeln('YES');
   writeln(g);
   halt;
  end;
 end;
 writeln('NO');
end.

var a,b,c,d,f,j,k:int64;
s:string;
i,e:longint;
arr:array [1..1000] of longint;
begin
read(a,b);
for i:=1 to (b div a) do begin
if b=a then begin writeln('YES'); write(i-1); halt; end;
a:=a*a;
end;
write('NO');
end.

var i,j,k,l,n,m,p,r,t:longint;
    a,b:array[1..100] of integer;
    s,s1,s2,s3:string;
begin

    read(k,l);

    n:=k;
    m:=0;
    while (n<l)and(n<>1) do
    begin
    n:=n*k;
    inc(m);
    end;

    if(n=l)and(k<>l) then begin writeln('YES');write(m);end
    else write('NO');

end.

var a,b,l,n:int64;
begin
 readln(a,b);
 l:=a;n:=0;
 while l<b do
  begin
   l:=l*a;
   inc(n);
  end;
 if l=b then begin writeln('Yes');writeln(n);end
        else writeln('NO');

end.

var k,l,i :longint;
begin
read (k,l);
i:=1;
while i<=l do
begin
if i<l then i:=i*k;
if i=l then
   begin
     Writeln ('YES');
     exit;
   end;
end;
Writeln('NO');
end.

var
  k,l,i,s:longint;
begin
  readln(k);
  read(l);
  i:=1;
  s:=1;
  while s<l do
  begin
    inc(i);
    s:=s*k;
  end;
  if s=l then begin writeln('YES'); write(i-1); end
         else write('NO');
end.

var l,i:integer;
k:qWord;
begin
i:=0;
readln(k);
readln(l);
while k<l do
begin
k:=k*k;
i:=i+1;
end;
if k=l then begin writeln('YES'); write(i); end else write('NO');
end.

Var n,k:int64;
    i:longint;
 begin
   Read(k,n);
   for i:=1 to 100 do
    begin
      k:=k*k;
      if k=n then begin writeln('YES'); writeln(i); exit; end;
      if k>n then begin writeln('NO');exit; end;
    end;

 end.

var i:integer;
k,l,m:int64;
begin
read(k,l);
i:=0;
while l mod k =0 do
begin
l:=l div k;
inc(i)
end;
if l=1 then begin writeln('YES'); write(i) end else write('NO')
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var i,n,j:integer;
    k,l:int64;
    s:string;
function pow(k:int64; m:integer):int64;
var ans,i:integer;
begin
ans:=1;
for i:=1 to m do
ans:=ans*k;
pow:=ans;
end;

begin
readln(k,l);
for j:=1 to 100 do
  if pow(k,j)>l then begin writeln('NO'); halt; end
                else if pow(k,j)=l then begin writeln('YES'); writeln(j-1); readln; halt; end;

end.

program uio;
 var k,l,z,kol:int64;

BEGIN

 readln(k);
 readln(l);
 z:=0; kol:=k;
  while true do
   begin
    kol:=kol*k; inc(z);
    if kol>l then begin writeln('NO'); halt; end;
    if kol=l then begin writeln('YES'); writeln(z); halt;  end;
   end;

END.

var k,l,p:integer;
begin
     readln(k,l);
     if l mod k<>0 then begin writeln('NO'); exit; end
     else while (l<>1) and (l<>0) do
     begin
          l:=l div k;
          inc(p);
          if l=0 then begin writeln('NO'); exit; end;
          if l=1 then begin writeln('YES'); writeln(p/2); exit; end;
     end;
end.

var
  k, l: real;
  i: longint;

begin
  read(k, l);
  i := 0;
  while (trunc(l) <> trunc(k)) and (trunc(l) > 1) do
  begin
    l := l / k;
    l := round(l);
    inc(i);
  end;
  if Trunc(l) = trunc(k) then
  begin
    writeln('YES');
    writeln(i);
  end
  else
    writeln('NO');
end.

var
 i,j,n,m,k,l:qword;
begin
 readln(k);
 readln(l);
 if k>l then begin k:=k+l; l:=k-l; k:=k-l; end;
 while (k<l) do
  begin
   k:=k*k;
   inc(m);
  end;
 if (k=l ) then begin
 writeln('YES');
 writeln(m);
 end
 else writeln('NO');
end.

{$I-,O+,Q-,R-,S-}

var
  k, l, ans: longint;
begin
  readln(k); readln(l);

  repeat
    if l mod k <> 0 then break;
    l := l div k;
    inc(ans);
  until l = 1;
  if ans = 0 then write('NO')
  else begin writeln('YES'); write(ans - 1); end;
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 x,y,k:integer;

procedure dar(x,y:integer);
 begin
 if y mod x = 0 then
                begin
                 y:=y div x;
                 k:=k+1;
                 if y>x then dar(x,y)
                 end
                else
                 write('NO');
 end;

begin
 readln(x);
 readln(y);
 dar(x,y);
 if(k>0) then begin
                writeln('YES');
                writeln(k);
              end;

  { TODO -oUser -cConsole Main : Insert code here }
end.

var
 i,j,n,m,k,l:int64;
begin
 readln(k,l);
 if ((k=0)and(l=0))or((k=1)and(l=1)) then  begin
 writeln('YES');
 writeln(0);
 halt;
 end
 else if ((k=0))or((k=1)) then begin halt; writeln('NO');  end;
 while (k<l) do
  begin
   K:=sqr(k);
   inc(m);
  end;
 if k=l then begin
 writeln('YES');
 writeln(m);
 end
 else writeln('NO');
end.

var i,j,n,m,k,s,o:longint;
begin
  readln(n,m);
  while m>0 do
  begin
    if m=1 then begin writeln('YES');writeln(o);halt;end;
    if (m mod n)<>0 then begin writeln('NO');halt;end;
    inc(o);
    m:=m div n;
  end;
end.

program cf114a;
var
   k,l,m:int64;

begin
   readln(k);
   readln(l);
   m:=0;
   while (k<=l) do begin

      if (l mod k=0) then begin
         l:=l div k;

         if (l=1) or (l=k) then begin
            writeln('YES');
            if l=k then m:=m+1;
            writeln(m);
            break;
         end else begin
            m:=m+1;
         end;
      end else begin
         writeln('NO');
         break;
      end;

   end;
end.

program zzz;
var i,n,a,b,x:word;
begin
  read(n);
  for i:=1to n do
    begin
      read(x);
      if odd(x)then inc(a)
      else inc(b)
    end;
  if odd(a)then write(a)
  else write(b);
end.

var  n,i,m:longint;
begin
    readln(n);
      readln(m);
         while n<=m do
            begin
             n:=n*n;
                inc(i);
               if m=n then break;
            end;
                 if m=n then begin writeln('YES'); writeln(i);end
                   else writeln('NO')
end.

var k,x,l:longint;
    i:integer;
begin
readln(k);
readln(x);
l:=k;
i:=0;
while x>=k do
  begin
  writeln(k);
  if x=k then
    begin
    writeln ('YES');
    writeln (i);
    exit;
    end;
  k:=k*l;
  i:=i+1;
  end;
writeln('NO');
end.

var
  a,s,d:int64;
begin
  read(a,s);
  while a<s do
  begin
  a:=sqr(a);
  inc(d);
  end;
  if sqrt(a)=sqrt(s) then BEGIN writeln('YES'); WRITE(D); END else write('NO');
  READLN();
  READLN()
end.

var
a,b,k,i:longint;
begin
reset (input);
rewrite (output);
readln (a); readln (b);
i:=0; k:=a;
repeat
    k:=k*a;
    i:=i+1;
until (k>=b);
if k=b then
    begin
        writeln ('YES');
        writeln (i);
    end
else
    writeln ('NO');
close (input);
close (output);
end.

var
 x,y,n,s:longint;
 p:boolean;
begin
 readln(x);
 readln(y);
 n:=1;
 s:=1;
 while (s*x<=y) and (p=false) do
  begin
   inc(n);
   s:=s*x;
   if s=y then p:=true;
  end;
 if p then begin writeln('YES'); writeln(n-1); end
        else writeln('NO');
end.

var i,j,k,n,m,p,r,t,l:longint;
    a,b:array[1..100] of integer;
    s,s1,s2,s3:string;
begin

    readln(k);
    read(l);

    n:=1;
    m:=0;
    t:=1;
    for i:=1 to 31 do
    begin
        n:=n*k;
        if l=n then begin writeln('YES');write(m);inc(t);break end;
        if n>l then break;
        inc(m);
    end;
    if t=1 then write('NO');

end.

program Project1;

{$APPTYPE CONSOLE}
var
   n, l, i: longint;
begin
  //reset(input, 'input.txt');
 // rewrite(output, 'output.txt');
  readln(n);
  readln(l);
  i := 0;
  while n <= l do
  begin
    n := n * l;
    inc(i);
    if n = l then
    begin
      writeln('YES');
      writeln(i);
      exit;
    end;
  end;
  writeln('NO');
end.

program A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k, l, i, l1 : int64;

begin

  read(l, k);

  if (l = 1) and (k = 1) then begin
    writeln('YES');
    writeln(0);
    halt;
  end;

  if (l = 1) and (k = -1) then begin
    writeln('YES');
    writeln(2);
    halt;
  end;

  if l = k then begin
    writeln('NO');
    halt;
  end;

  l1 := l;
  i := 0;
  while (l < k) and (i < 1000) do begin
    l := l * l1;
    inc(i);
  end;

  if l = k then begin
    writeln('YES');
    writeln(i);
    readln;readln;
    halt;
  end;

  writeln('NO');
  readln;readln;

end.

var l,i:integer;
k:qWord;
begin
i:=0;
readln(k);
readln(l);
while k<l do
begin
k:=k*k;
i:=i+1;
end;
if k=l then write('YES') else write('NO');
end.

const fi = '';
        fo = '';
var
        f : text;
        n,m,k,i : int64;
        p : boolean;
begin
        assign(f,fi);
        reset(f);
        readln(f,n);
        readln(f,m);
        Close(f);
        k := n;
        p := false;
        i := 0;
        repeat
                k := k*n;
                if k = m then p := true;
                inc(i);
        until (p = true) or (k > m);
        Assign(f,fo);
        rewrite(f);
        if p = true then
        Begin
                Writeln(f,'YES');
                Writeln(f,i);
        End
        else writeln(f,'NO');
        Close(f);
End.

var
k,l,i:int64;
function binpow(a,n:integer): int64;
begin
if (n=0) then binpow:=1 else
 if odd(n) then binpow:=binpow(a,n-1)*a else
  binpow:=binpow(a,n div 2)*binpow(a,n div 2);
end;

begin
read(k,l); i:=0;
while (k<=l) do begin
  if (l mod k <> 0) then begin writeln('NO'); exit; end;
  if (l = k) then begin writeln('YES'); writeln(i); exit; end;
  k:=k*k; inc(i);
 end;
writeln('NO');
end.

var a,b,c,d,f,j,k:int64;
s:string;
i,e:longint;
arr:array [1..1000] of longint;
begin
read(a,b);
for i:=1 to b do begin
if b=a then begin writeln('YES'); write(i-1); halt; end;
a:=a*a;
end;
write('NO');
end.

program zadanie12;
var a,k,l:real;
begin
readln(k);
readln(l);
a:=0;
if k=l then
begin
k:=l;
writeln('YES');
writeln(a);
end;
while l>k do
begin
k:=k*k;
a:=a+1;
if k=l then
begin
k:=l;
writeln('YES');
writeln(a);
end;
end;
if k<>l then writeln('NO');
end.

var x,y,i: int64;

begin
  i:=0;
  readln(x,y);
  repeat
  if y mod x <> 0 then
  begin
  writeln('NO');
  exit;
  end
  else
  y:=y div x;
  i:=i+1;
  until y<>x;
  writeln('YES');
  if i = 0 then  writeln('0') else writeln(i-1);
  end.

Var osn,ch,step:longint;
begin
read(osn);
readln(ch);
while (ch div osn<>1) and
(ch mod osn=0) do begin
step:=step+1;
ch:=ch div osn;
end;
if (step=0) and
(ch<>1) then writeln('NO') else begin writeln('YES');
writeln(step);   end;
end.

Var i,a,b,a1:longint;
begin
readln(a,b);
i:=0;
a1:=a;
while (a<>b) and (b>a) do begin
i:=i+1;
a:=a*a1;
if a=b then begin writeln('YES'); writeln(i); exit; end;
end;
writeln('NO');
end.

program cifera;
var
k,l,md,f : integer;
la,i,n : integer;
begin
        readln(k);
        readln(l);
        md:= l mod k;

            la:= -1 ;

        if md = 0 then
        begin
        while l <> 1 do
        begin
                l:= l div k;
                la:= la + 1;

        end;
         writeln('YES');
         writeln(la)
         end
         else
         writeln('NO');
end.

var k,l:longint;
begin
  read(k,l);
  while l mod k=0 do l:=l div k;
  if l=1 then write('YES')else write('NO');
end.

var k,x,l:longint;
    i:integer;
begin
readln(k);
readln(x);
l:=k;
i:=0;
while x>=k do
  begin
  writeln(k);
  if x=k then
    begin
    writeln ('YES');
    writeln (i);
    exit;
    end;
  k:=k*l;
  i:=i+1;
  end;
writeln('NO');
end.

program cf114a;
var
   k,l,m:int64;

begin
   readln(k);
   readln(l);
   m:=0;
   if k<=l then begin
     while (k<=l) do begin

      if (l mod k=0) then begin
         l:=l div k;

         if (l=1) or (l=k) then begin
            writeln('YES');
            if l=k then m:=m+1;
            writeln(m);
            exit;
         end else begin
            m:=m+1;
         end;
      end else begin
         writeln('NO');
         exit;
      end;

     end;
   end else writeln('NO');
end.

var k, l, ans, a : int64;
begin
 readln(k,l);
 a := k;
 ans := 1;
 while a < l do
 begin
  if a * a <= l then begin a := a * a; ans := ans * 2; end
   else a := a * k;
 end;
 if a = l then begin
                writeln('YES');
                writeln(ans - 1);
               end else writeln('NO');
end.

var k,x,i,l:longint;
begin
readln(k);
readln(x);
i:=0;
l:=k;
while  (k*l)<=x+1 do
begin
k:=k*l;
i:=i+1;
if k=x then begin writeln('YES'); writeln(i); k:=0; break; end;
end;
if k<>0 then writeln('NO');
end.

program zadacha1;
var   k,l:longint;  x:integer;
begin
{
assign(input,'input.txt');
assign(output,'output.txt');
reset(input); rewrite(output);
}
readln(k);
readln(l);

if l mod k<>0 then write('NO');

x:=0;
while k<l do begin
l:=l div k;
inc(x);
end;
if k=l then begin
writeln('YES');
write(x); end;
{close(input); close(output);}
end.

var
   n,k,count:integer;
begin
readln(n);
readln(k);
Count:=1;
while n<=k do
      begin
           n:=n*n;
           inc(count);
           if n = k then begin
              writeln('YES');
              writeln(Count-1);
              Exit;
           end;
      end;
writeln('NO');
end.

var  n,i,m:longint;
begin
    readln(n);
      readln(m);
         while m<n do
            begin
             m:=m*m;
                inc(i);
               if m=n then break;
            end;
                 if m=n then begin writeln('YES'); writeln(i);end
                   else writeln('NO')
end.

var s, i, k, l: integer;
begin
readln(k);
readln(l);
while (l div k) >= k do begin
i:=i+1;
if l mod k <> 0 then begin s:=1;l:=l div k end else
l:=l div k
end;
if s <> 1 then if l = k then begin
writeln('YES');
write(i)
end else write('NO') else write('NO')
end.

Uses math;

var
    K, L: int64;
    e: double;

begin

    readln(K, L);

    if (K = 1) then begin
       if (L = 1) then begin
            writeln('YES');
            writeln(0);
       end else
            writeln('NO');
    end else begin

        e := ln(L)/ln(K);

        if (ABS(ceil(e) - e) < 0.0000001) then begin
            writeln('YES');
            writeln(ceil(e) - 1);
        end else
            writeln('NO');
    end;
end.

var x,y,i: int64;

begin
  i:=0;
  readln(x,y);
  repeat
  if y mod x <> 0 then
  begin
  writeln('NO');
  exit;
  end
  else
  y:=y div x;
  i:=i+1;
  until y<>x;
  if i < 2 then  writeln('NO') else begin
  writeln('YES');
  writeln(i-1);
  end;
  end.

Var a,b,i:longint;
Begin
readln(a,b);
i:=0;
while (b>a) do
begin
i:=i+1;
a:=a*a;
if a=b then begin
            writeln('YES');
            writeln(i);
            exit;
            end;
end;
writeln('NO');
end.

program A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k, l, i, l1 : int64;

begin

  read(l, k);
       {
  if (l = 1) and (k <> 1) then begin
    writeln('YES');
    writeln(0);
    halt;
  end;}

  if l = k then begin
    writeln('NO');
    halt;
  end;

  l1 := l;
  i := 0;
  while (l < k) and (i < 1000) do begin
    l := l * l1;
    inc(i);
  end;

  if l = k then begin
    writeln('YES');
    writeln(i);
    readln;readln;
    halt;
  end;

  writeln('NO');
  readln;readln;

end.

program A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k, l, i, l1 : int64;

begin

  read(l, k);

  if (k < l) then begin
    writeln('NO');
    readln;readln;
    halt;
  end;

  if (l = 1) and (k = 1) then begin
    writeln('YES');
    writeln(1);
    readln;readln;
    halt;
  end;

  if (l = -1) and (k = -1) then begin
    writeln('YES');
    readln;readln;
    writeln(2);
    halt;
  end;

  if l = k then begin
    writeln('NO');
    readln;readln;
    halt;
  end;

  l1 := l;
  i := 0;
  while (l < k) and (i < 1000) do begin
    l := l * l1;
    inc(i);
  end;

  if l = k then begin
    writeln('YES');
    writeln(i);
    readln;readln;
    halt;
  end;

  writeln('NO');
  readln;readln;

end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a:array[1..1000000] of string;
  k,j,n,i:Integer;
  s:string;
  f:Int64;
function lol(n,f:Integer):Integer;
var
  i,k,j:Integer;
begin
  k:=0;
  j:=n;
  for i:=1 to 100 do
    begin
      if (n=f) then Break;
      n:=n*j;
      inc(k);
    end;
  if (f=n) then lol:=k
    else lol:=0;
end;
begin
  Readln(n);
  Readln(k);
  if (lol(n,k)>0) then write(lol(n,k))
    else write('NO');
  Readln;
  Readln;
end.

var  n,i,m:longint;
begin
    readln(n);
      readln(m);
         while n<=m do
            begin
             n:=n*n;
                inc(i);
               if m=n then break;
            end;
                 if m=n then begin writeln('YES'); writeln(i);end
                   else writeln('NO')
end.

var x,y,i: longint;

begin
  readln(x,y);
  repeat
  if y mod x <> 0 then
  begin
  writeln('NO');
  exit;
  end
  else
  y:=y div x;
  i:=i+1;
  until y<>x;
  writeln('YES');
  writeln(i);
  end.

var a,b,l,n:int64;
begin
 readln(a,b);
 l:=a;n:=1;
 while l<b do
  begin
   l:=l*a;
   inc(n);
  end;
 if l=b then begin writeln('Yes');writeln('1');end
        else writeln('NO');

end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s,k,l,count:integer;

begin
  { TODO -oUser -cConsole Main : Insert code here }
readln(k);
readln(l);
s:=k;
while l*l>s do
begin
if s<>l then
begin
s:=s*k;
inc(count);
end
else
begin
writeln('YES');
writeln(count);
exit;
end;
end;
writeln('NO');
end.

var
  k,l:longint;
begin
  readln(k);
  readln(l);
  if trunc(sqrt(l))=sqrt(l) then
    begin
      writeln('YES');
      write(trunc(sqrt(l))-1);
      halt;
    end;
  write('NO');
end.

var k,l,t:int64;
begin
 readln(k);
 readln(l);
 if l mod k<>0 then begin writeln('NO');exit;end;
 t:=0;
 while l>k do begin
  if l mod k =0 then begin t:=t+1;l:=l div k;end else
   begin writeln('NO');exit;end;end;
 writeln('YES');
 writeln(t);
 end.

var
 i,j,n,m,k,l:int64;
begin
 readln(k);
 readln(l);
 while (l>k) do
  begin
   l:=l div 5;
   inc(m);
  end;
 if (l=k) then begin
 writeln('YES');
 writeln(m);
 end
 else writeln('NO');
end.

var k,x,i,l:longint;
begin
readln(k);
readln(x);
i:=0;
if k=x then writeln('NO')
else
begin
l:=k;
while  (k*l)<=x+1 do
begin
k:=k*l;
i:=i+1;
if k=x then begin writeln('YES'); writeln(i); k:=0; break; end;
end;
if k<>0 then writeln('NO');
end;
readln;
end.

var i,j,k,l,n,m,p,r,t:longint;

begin

    read(k,l);

    n:=k;
    while (n<l)and(n<>1) do
    n:=n*k;

    if(n=l)and(k<>l) then write('YES')
    else write('NO');

end.

program zadanie12;
var a:integer; k,l:real;
begin
readln(k);
readln(l);
a:=0;
if k=l then
begin
k:=l;
writeln('YES');
writeln(a);
end;
while l>k do
begin
k:=k*k;
a:=a+1;
if k=l then
begin
k:=l;
writeln('YES');
writeln(a);
end;
end;
if k<>l then writeln('NO');
end.