#include <iostream>
#include <vector>

int main()
{
    int64_t n, k;
    std::cin >> n >> k;
    
    int64_t cur = 0;
    int64_t answer = 0;
    for(int i=1; i<=n; i++)
    {
        std::vector<int> digits;
        int v = i;
        while(v > 0)
        {
            digits.push_back(v % 10);
            v /= 10;
        }
        for(int j=digits.size()-1; j>=0; j--)
        {
            cur = (cur * 10) % k;
            cur = (cur + digits[j]) % k;
        }
        if(cur == 0)
            answer++;
    }
    std::cout << answer << std::endl;
}
