N = int(input()) M = int(input()) N //= 1000 N %= M ans = 1 for i in range(M, M - N, -1): ans *= i for i in range(1, N + 1): ans //= i print(ans)