PROGRAM MARCH;
VAR N,P:INTEGER;NF:LONGINT;I:INTEGER;B:BOOLEAN;
FUNCTION FACT(G:INTEGER):LONGINT;
BEGIN
IF (G=1) THEN FACT:=1 ELSE FACT:=G*FACT(G-1);
END;
BEGIN
READLN(N,P);NF:=0;B:=FALSE;
IF P=1 THEN WRITELN(FACT(N-1));
IF P=N THEN BEGIN WRITELN('1');B:=TRUE;END;
IF (P=2)AND(B=FALSE) THEN BEGIN
FOR I:=1 TO N-1 DO
NF:=NF+((FACT(N-1))DIV I);
WRITELN(NF);END;
IF ((P=3)OR(P MOD 2=1))AND(B=FALSE) THEN BEGIN
FOR I:=2 TO N-1 DO
NF:=NF+((FACT(I))DIV 2)+1;
WRITELN(NF);END;
IF (P=4)AND(B=FALSE) THEN BEGIN
FOR I:=2 TO N-1 DO
NF:=NF+(FACT(N-I)DIV 2);
WRITELN(NF);END;
IF (P<>4)AND(P<>2)AND(P MOD 2=0)AND(B=FALSE) THEN BEGIN
FOR I:=2 TO N-1 DO
NF:=NF+(FACT(N-I)DIV 2);
WRITELN(NF);END;
END.
