using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace YukiCoder2 { class Program { static void Main(string[] args) { ulong n = Console.ReadLine().Split(' ').Select(ulong.Parse).ToArray()[0]; ulong m = Console.ReadLine().Split(' ').Select(ulong.Parse).ToArray()[0]; ulong rest = (n /1000L) % m; if (rest == 0) { Console.WriteLine("1"); return; } var buffer = new ulong[m+1,m+1]; for (ulong i = 0; i < m+1; i++) { buffer[i, 0] = 1; buffer[i, i] = 1; } for (ulong i = 1; i < m+1; i++) { for (ulong k = 1; k < i; k++) { buffer[i, k] = buffer[i - 1, k - 1] + buffer[i - 1, k]; } } Console.WriteLine(buffer[m,rest]); } } }