N = int(input()) M = int(input()) a = N//1000//M b = N - (a * M) * 1000 c = b//1000 def perm(n, k): result = 1 for i in range(1, k + 1): result *= (n - i + 1) result //= i return result print(perm(M, c)%1000000000)