#include<iostream>
using namespace std;
int main() {
int n, x,count;
cin >> n >> x;
if (n < x) {
cout << "0";
return 0;
}
else {
if (n >= x && n < 10) {
cout << "1";
return 0;
}
else {
count = 1;
for (int i = 10; i <= n; i++) {
int j = 10;
while (j <= i) {
if (i % j / (j / 10) == x) {
count++;
}
if (i / j == x&&i/j!=0) {
count++;
}
j *= 10;
}
}
}
}
cout << count << endl;
return 0;
}