# -*- coding:utf-8 -*- from scipy.misc import comb if __name__ == "__main__": n = input() m = input() n /= 1000 n %= m if n == 0: print 1 exit() else: print comb(m,n) % (10**9)