import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final long N = sc.nextLong(); final int M = sc.nextInt(); int[][] nCk = new int[M + 1][M + 1]; nCk[0][0] = 1; for(int i = 0; i < M; i++){ for(int j = 0; j <= i; j++){ nCk[i + 1][j] += nCk[i][j]; nCk[i + 1][j] %= 1000000000; nCk[i + 1][j + 1] += nCk[i][j]; nCk[i + 1][j + 1] %= 1000000000; } } final long one_person = N / 1000 / M * 1000; final long rest = N - M * one_person; final int k = (int)(rest / 1000); System.out.println(nCk[M][k]); } }