int main() {
    int n, x, sum = 0;
    while (scanf("%d %d", &n, &x) != EOF) {
        for (int i = 1; i <= n; i++) {
            int temp = i;
            while (temp) {
                if (temp % 10 == x) sum++;
                temp /= 10;
            }
        }
        printf("%d", sum);
    }
}