from collections import * import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def MF(): return map(float, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LF(): return list(map(float, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def com(com_n, com_r): return fac[com_n] * inv[com_r] * inv[com_n - com_r] % md md = 10**9 n_max = 10005 fac = [1] k_fac_inv = 1 for i in range(1, n_max + 1): k_fac_inv = k_fac_inv * i % md fac.append(k_fac_inv) def com(com_n, com_r): return fac[com_n]//fac[com_r]//fac[com_n-com_r]%md def main(): n = II() m = II() n //= 1000 hit = n % m print(com(m, hit)) main()