# your code goes here N=int (input ()) M=int(input()) N//=1000 N%=M if N==0: print(1) else: L=1000000000 if N>=M//2: N=M-N # print(N) Mb=1 for i in range (N): Mb*=M-i # print(M) if Mb>1000000000: Mb%=1000000000 for i in range (N): Mb//=N-i # if Mb>1000000000: # N%=1000000000 print (Mb)