import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); long n = koko.nextLong(); int m = koko.nextInt(); long nama = n % 1000; long nmai = (n - nama) / 1000; long amari = nmai % m; if (amari == 0) { System.out.println(1); } else { int[][] judge = new int[m + 1][m + 1]; for (int i = 0; i < m + 1; i++) { judge[0][i] = 1; judge[i][0] = 1; } for (int i = 1; i < m + 1; i++) { for (int j = 1; j < m + 1; j++) { judge[i][j] = (judge[i - 1][j] + judge[i][j - 1]) % 1000000000; } } long ans = judge[(int) (m - amari)][(int) amari]; System.out.println(ans); } } }