#include <ios>
#include <iostream>
using namespace std;

int main() {
    int n, x, count = 0;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> x;
    for (int i = max(1, x); i <= n; i++) {
        int t = i;
        while (t) {
            if (t % 10 == x) {
                count++;
            }
            t /= 10;
        }
    }
    cout << count;
}
// 64 位输出请用 printf("%lld")