using System; using System.Collections; using System.Collections.Generic; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ long rest=(N-N/M/1000*1000*M)/1000; if(rest>=M)rest=M; int[][] nCr=new int[2][]; nCr[0]=new int[10001]; nCr[0][0]=1; int now=1;int prev=0; int mod=(int)1e9; for(int i=1;i<=M;i++){ now=i%2; prev=now^1; nCr[now]=new int[10001]; nCr[now][0]=1; for(int j=1;j<=10000;j++){ nCr[now][j]=(nCr[prev][j-1]+nCr[prev][j])%mod; } } Console.WriteLine(nCr[now][rest]); } long N,M; public Sol(){ N=rl();M=rl(); } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(){return Console.ReadLine().Split(' ');} static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} }