import java.math.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); int m = sc.nextInt(); long nokori = n/1000*1000-n/1000/m*1000*m; nokori/=1000; long ans = 1; BigInteger bigInteger = new BigInteger("1"); for(int i=0;i<(int)nokori;i++){ bigInteger=bigInteger.multiply(new BigInteger(""+m).subtract(new BigInteger(""+i))); bigInteger=bigInteger.divide(new BigInteger(""+(i+1))); } System.out.println(bigInteger.mod(new BigInteger("1000000000"))); } }