import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long MOD = (long)Math.pow(10, 9); long[][] dp = new long[10001][10001]; dp[0][0] = 1; for(int i = 1; i < 10001; i++) { dp[i][0] = 1; for(int j = 1; j <= i; j++) { dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % MOD; } } long N = sc.nextLong(); long M = sc.nextLong(); N /= 1000; long r = N % M; System.out.println(dp[(int)M][(int)r]); } }