def fact(n): return 1 if n == 0 else n*fact(n-1) N = int(raw_input()) M = int(raw_input()) R = (N-N/1000/M*1000)/1000 print fact(M)/fact(R)