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[1]; c[0]=1; for(int i=0; i=MOD) nc[j]-=MOD; nc[j+1]+=c[j]; if(nc[j+1]>=MOD) nc[j+1]-=MOD; } c=nc; } out.println(c[x]); out.close(); scanner.close(); } }