import java.util.*; 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{ long bunsi = kaijo(m, amari, 1); long bunbo = kaijo(amari, amari, 1); System.out.println(bunsi/bunbo); } } static long kaijo(long a, long b, long c){ if(b==0){ return c; }else{ long d = 0; if(a%1000000000==0){ d=1; }else{ d=a%1000000000; } return kaijo(a-1, b-1, c*d%1000000000); } } }