import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long N = sc.nextLong() / 1000; int M = sc.nextInt(); N %= M; final int MOD = 1000000000; BigInteger ans = new BigInteger("1"); // M_C_N を求めれば良い if (N == 0) { System.out.println(1); return; } for (int i = 1; i <= N; i++) { ans = ans.multiply(new BigInteger(String.valueOf(M - i + 1))); ans = ans.divide(new BigInteger(String.valueOf(i))); } ans = ans.mod(new BigInteger(String.valueOf(MOD))); System.out.println(ans.toString()); } }