import java.io.PrintWriter; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scanner=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); long n=Long.parseLong(scanner.next()); int m=Integer.parseInt(scanner.next()); int x=(int)(n/1000%m); final int MOD=1000000000; int[] c=new int[m+1]; c[0]=1; for(int i=0; i=1; j--) { c[j]+=c[j-1]; if(c[j]>=MOD) c[j]-=MOD; } } out.println(c[x]); out.close(); scanner.close(); } }