from math import factorial as fact N = input()/1000 M = input() print fact(M)/fact(M-N%M)/fact(N%M) % (10**9)