Function summa(x:real; n:integer):real;
var
s,step:
real;
i:integer;
begin
step:=cos(2*x);
if n>1 then
begin
for i:=2 to n do
step:=step*cos(2*x);
summa:=summa(x,n-1)+step;
end
else
summa:=cos(2*x);
end;
var
x:real;
n:integer;
begin
write('X = ');
readln(x);
write('N = ');
readln(n);
writeln('S = ',summa(x,n-1)+1:0:3);
end.