#include <stdio.h>

int main() {
    int n, x;
    scanf("%d %d", &n, &x);
    int i;
    int cnt = 0;
    for (i = 1; i <= n; i++) {
        int k = i;
        if (k < 10) {
            if (k == x) {
                cnt++;
            }
        }
        if(k> 9) {
            while (k > 0) {
                int t = k % 10;
                if (t == x) {
                    cnt++;
                }
                k = k / 10;
            }
        }
    }
    printf("%d", cnt);
    return 0;
}