program tinh;
uses crt;
var i,n,x:integer;
t:longint;
function luythua(n,x:integer):longint;
var m:integer;
begin
m:=1;
for i:=1 to n do
m:=m*x;
luythua:=m;
end;
function giaithua(n:integer):longint;
begin
if n=0 then giaithua:=1
else giaithua:=n*giaithua(n-1);
end;
begin
clrscr;
write('nhap n,x:');readln(n,x);
t:=0;
for i:=1 to n do
t:=t+giaithua(luythua(i,x));
writeln(t);
readln;
end.