import java.util.*; import java.math.BigInteger; public class Exercise100{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long m = sc.nextLong(); long mod = 1000000000; if((n / 1000) % m == 0){ System.out.println(1); }else{ long bills = ((n / 1000) % m); BigInteger a = BigInteger.ONE; for(long i = 0; i < bills; i++){ a = a.multiply(BigInteger.valueOf(m - i)); a = a.divide(BigInteger.valueOf(i + 1)); } System.out.println(a.remainder(BigInteger.valueOf(mod))); } } }