import java.util.Scanner; public class Main_yukicoder129 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int MOD = 1_000_000_000; long n = sc.nextLong() / 1000; int m = sc.nextInt(); int a = (int)(n % m); int[][] p = new int[2][m + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= i; j++) { if (j == 0 || j == i) { p[i % 2][j] = 1; } else { p[i % 2][j] = (p[(i + 1) % 2][j - 1] + p[(i + 1) % 2][j]) % MOD; } } } System.out.println(p[m % 2][a]); sc.close(); } }