import java.util.* ;
interface cc_tgr {
   static void main(String[] args) {
      Scanner sc = new Scanner(System.in) ;
      long n = sc.nextLong() ;
      long k = sc.nextLong() ;
      long v = 0 ;
      long m = 10 ;
      long r = 0 ;
      for (long i=1; i<=n; i++) {
         if (i >= m)
            m *= 10 ;
         v = (v * m + i) % k ;
         if (v == 0)
            r++ ;
      }
      System.out.println(r) ;
   }
}
