var
n,p,i,y,s,j:longint;
a:array[1..100000000] of integer;
begin
assign(input,'cruel1.in');reset(input);
assign(output,'cruel1.out');rewrite(output);
readln(n,p);s:=1;
i:=1;
y:=p div 2;a[i]:=p mod 2;inc(i);
while y<>0 do
begin
a[i]:=y mod 2;
inc(i);
y:=y div 2;
end;
dec(i);
for j:=i downto 1 do
if a[j]=1 then s:=s*s*n else s:=s*s;
writeln(s);
close(input);close(output);
end.