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[][] judge = new long[m+1][m+1]; for(int i=0; i