var n,i: integer; x,xn,y: real;
begin
readln(x, n);
xn:=1;
y:=0;
for i:=1 to n do
xn:=xn*x;
y:=y+cos(xn);
end;
writeln(y);
end.
var n,i: integer; x,xn,y: real;
begin
readln(x, n);
xn:=1;
y:=0;
for i:=1 to n do
begin
xn:=xn*x;
y:=y+cos(xn);
end;
writeln(y);
end.