A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.Let's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 ≤ i ≤ n) such that pi = i.Your task is to count the number of almost identity permutations for given numbers n and k.

The first line contains two integers n and k (4 ≤ n ≤ 1000, 1 ≤ k ≤ 4).

Print the number of almost identity permutations for given n and k.

program Almost_Identity_Permutations;

const
   maxn = 1003;
   maxk = 4;

var
   n, k: longint;
   ans: int64;

begin
   readln(n, k);

   ans := 1;
   if k >= 2 then inc(ans, int64(n) * (n - 1) div 2);
   if k >= 3 then inc(ans, int64(n) * (n - 1) * (n - 2) div 6 * 2);
   if k >= 4 then inc(ans, int64(n) * (n - 1) * (n - 2) * (n - 3) div 24 * 9);

   writeln(ans);
end.

var
    n,k,kq:int64;
    f:array[0..5] of int64;

procedure enter;
    begin
    readln(n,k);
    end;

procedure process;
var i:longint;
    begin
    f[0]:=1;
    f[1]:=0;
    f[2]:=n*(n-1) div 2;
    f[3]:=n*(n-1)*(n-2) div 3;
    f[4]:=n*(n-1)*(n-2)*(n-3)*9 div 24;
    for i:=0 to k do
        kq:=kq+f[i];
    write(kq);
    end;

begin
    enter;
    process;
end.

var n,k:int64;
f:array[0..4] of int64;
procedure       mo;
begin
        assign(input,'test.inp');reset(input);
        assign(output,'test.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;
procedure       nhap;
begin
        readln(n,k);
end;
procedure       xuli;
var res:int64;i:longint;
begin
        res:=0;
        f[0]:=1;
        f[1]:=0;
        f[2]:=(n*(n-1)) div 2;
        f[3]:=(n*(n-1)*(n-2))div 3;
        f[4]:=(n*(n-1)*(n-2)*(n-3))*9 div 24;
        for i:=0 to k do
                res:=res+f[i];
        writeln(res);
end;
begin
        //mo;
        nhap;
        xuli;
        //dong;
end.

const fi='888D.inp';
        fo='888D.out';
var n,k,kq:int64;
procedure conan;
        begin
                kq:=1;
                if k=1 then exit;
                kq:=kq+n*(n-1) div 2;
                if k=2 then exit;
                kq:=kq+n*(n-1)*(n-2)*2 div 6;
                if k=3 then exit;
                kq:=kq+n*(n-1)*(n-2)*(n-3) * 9 div 24;
        end;
begin

        readln(n,k);
        conan;
        writeln(kq);
end.

Var     n,k: Int64;
        f: Array[0..4] Of QWord;

Procedure       Nhap;
Begin
Readln(n,k);
End;

Procedure       XuLy;
Begin
f[0]:=1;
f[1]:=0;
f[2]:=(n*(n-1)) div 2;
f[3]:=(n*(n-1)*(n-2)) div 3;
f[4]:=((n*(n-1)*(n-2)*(n-3))*3) div 8;
End;

Procedure       Xuat;
Var     i: Longint;
        kq: QWord;
Begin
kq:=0;
For i:=0 to k do
        kq:=kq+f[i];
Writeln(kq);
End;

Begin
Nhap;
XuLy;
Xuat;
End.

Program AFSA;
var n,k,i:longint;
    g1,g2,g3,g4:int64;
 begin
read(n,k);
if k=1 then writeln(1);

g2:=1;
for i:=n-1 to n do
  g2:=g2*i;
for i:=1 to 2 do
  g2:=g2 div i;

if k=2 then writeln(g2+1);

g3:=1;
for i:=n-2 to n do
  g3:=g3*i;
for i:=1 to 3 do
  g3:=g3 div i;
g3:=g3*2;

if k=3 then writeln(g2+g3+1);

g4:=1;
for i:=n-3 to n do
  g4:=g4*i;
for i:=1 to 4 do
  g4:=g4 div i;
g4:=g4*9;
  if k=4 then writeln(1+g2+g3+g4);

//writeln(1, ' ', g2, ' ', g3, ' ',g4);

{
2143
2341
2413
3142
3412
3421
4123
4321
4312
}

end.

   const eps=0.0000000001;    nn=200000; besk=8000000000;
   label 1,2,23;
    type    real=extended;  {string=ansistring;}
    mas=array [0..nn] of int64;   point=record x,y,z:real;end;
    ppoint=^point;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var aa,bb,cc,pos,kk,t3,ot,prod,ost,kol,zapas,dist,r,ll,rr,sum,q,h,t1,t2,modul,t,tt,time,p,gr,qq,pmax,imax,p1,p2,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl,i1:int64;
    ii,jj,step, k,i,j:longint;
   {  aa,bb,cc:int64;
   }  pp:array[-1000 ..1000] of point;
     fact,slow,z,pr,next,d1,d2,aold,b,a,x,y:array[-1000..2000000] of int64;
     dd:array[-10..2000,-10..200] of int64;
   zanx,zany:array[-10..20000000] of boolean;
    marked,zan:array[-10..10000000] of boolean;
    ss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ch:char;
    d :array [-10..250000,-1..50] of int64;
    dda:array [0..201,-10..30] of int64;
    sss:array[-10..500000] of string;
    st2:array[0..nn] of string;
     pr1,pr2,v0,v1,s0,t0:extended;
     zv:point;
     prob:array[-1..200,-1..200] of extended;

     yot:double;
     qqq,aaa,bbb,ccc:extended;
       flag,flag1:boolean;
    function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

function dom(length,num:longint):boolean;
var t,i,j:longint; fll,fl:boolean;
begin
    fl:=true;
    for i:=1 to n-length+1 do if d[i+length-1,num]-d[i-1,num]=0 then fl:=false;

    dom:=fl;

end;

function domm(length:longint):boolean;
var i,j:longint; fl:boolean;
begin
  fl:=false;
  for i:=0 to 25 do if dom(length,i) then fl:=true;

  domm:=fl;
end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
      read(n,p);
      a[2]:=n*(n-1) div 2;
      a[3]:=n*(n-1)*(n-2) div 6;
      a[4]:=n*(n-1)*(n-2)*(n-3) div 24;
      b[2]:=1;
      b[3]:=2;
      b[4]:=9;

      ot:=1;
      for i:=2 to p do ot:=ot+a[i]*b[i];

      writeln(ot);

   1:          close(output);
end.

var
    n,k,kq:longint;
    f:array[0..5] of int64;

procedure enter;
    begin
    readln(n,k);
    end;

procedure process;
var i:longint;
    begin
    f[0]:=1;
    f[1]:=0;
    f[2]:=n*(n-1) div 2;
    f[3]:=n*(n-1)*(n-2) div 3;
    f[4]:=n*(n-1)*(n-2)*(n-3)*9 div 24;
    for i:=0 to k do
        kq:=kq+f[i];
    write(kq);
    end;

begin
    enter;
    process;
end.

Var     n,k: Longint;
        f: Array[0..4] Of Int64;

Procedure       Nhap;
Begin
Readln(n,k);
End;

Procedure       XuLy;
Begin
f[0]:=1;
f[1]:=0;
f[2]:=(n*(n-1)) div 2;
f[3]:=(n*(n-1)*(n-2)) div 3;
f[4]:=((n*(n-1)*(n-2)*(n-3))*3) div 8;
End;

Procedure       Xuat;
Var     i,kq: Longint;
Begin
kq:=0;
For i:=0 to k do
        kq:=kq+f[i];
Writeln(kq);
End;

Begin
Nhap;
XuLy;
Xuat;
End.

Var     n,k: Longint;
        f: Array[0..4] Of Longint;

Procedure       Nhap;
Begin
Readln(n,k);
End;

Procedure       XuLy;
Begin
f[0]:=1;
f[1]:=0;
f[2]:=(n*(n-1)) div 2;
f[3]:=(n*(n-1)*(n-2)) div 3;
f[4]:=((n*(n-1)*(n-2)*(n-3))*3) div 8;
End;

Procedure       Xuat;
Var     i,kq: Longint;
Begin
kq:=0;
For i:=0 to k do
        kq:=kq+f[i];
Writeln(kq);
End;

Begin
Nhap;
XuLy;
Xuat;
End.

Program AFSA;
var n,k,g1,g2,g3,g4,i:longint;

begin
read(n,k);
if k=1 then writeln(1);

g2:=1;
for i:=1 to n do
  g2:=g2*i;
for i:=1 to k do
  g2:=g2 div i;
for i:=1 to n-k do
  g2:=g2 div i;

if k=2 then writeln(g2+1);

g3:=1;
for i:=1 to n do
  g3:=g3*i;
for i:=1 to k do
  g3:=g3 div i;
for i:=1 to n-k do
  g3:=g3 div i;
g3:=g3*2;

if k=3 then writeln(g2+g3+1);

g4:=1;
for i:=1 to n do
  g4:=g4*i;
for i:=1 to k do
  g4:=g4 div i;
for i:=1 to n-k do
  g4:=g4 div i;
g4:=g4*12;
  if k=4 then writeln(1+g2+g3+g4);

{
2143
3412
4321
4123
2341
2413
2431

}

end.

Program AFSA;
var n,k,g1,g2,g3,g4,i:longint;

begin
read(n,k);
if k=1 then writeln(1);

g2:=1;
for i:=1 to n do
  g2:=g2*i;
for i:=1 to 2 do
  g2:=g2 div i;
for i:=1 to n-2 do
  g2:=g2 div i;

if k=2 then writeln(g2+1);

g3:=1;
for i:=1 to n do
  g3:=g3*i;
for i:=1 to 3 do
  g3:=g3 div i;
for i:=1 to n-3 do
  g3:=g3 div i;
g3:=g3*2;

if k=3 then writeln(g2+g3+1);

g4:=1;
for i:=1 to n do
  g4:=g4*i;
for i:=1 to 4 do
  g4:=g4 div i;
for i:=1 to n-4 do
  g4:=g4 div i;
g4:=g4*9;
  if k=4 then writeln(1+g2+g3+g4);

//writeln(1, ' ', g2, ' ', g3, ' ',g4);

{
2143
2341
2413
3142
3412
3421
4123
4321
4312
}

end.

Program AFSA;
var n,k,g1,g2,g3,g4,i:longint;

begin
read(n,k);
if k=1 then writeln(1);

g2:=1;
for i:=n-1 to n do
  g2:=g2*i;
for i:=1 to 2 do
  g2:=g2 div i;

if k=2 then writeln(g2+1);

g3:=1;
for i:=n-2 to n do
  g3:=g3*i;
for i:=1 to 3 do
  g3:=g3 div i;
g3:=g3*2;

if k=3 then writeln(g2+g3+1);

g4:=1;
for i:=n-3 to n do
  g4:=g4*i;
for i:=1 to 4 do
  g4:=g4 div i;
g4:=g4*9;
  if k=4 then writeln(1+g2+g3+g4);

//writeln(1, ' ', g2, ' ', g3, ' ',g4);

{
2143
2341
2413
3142
3412
3421
4123
4321
4312
}

end.