#include <stdio.h>
void times(int n,int x,int *count){
    while(n>0){
        if(n%10==x){
            (*count)++;
        }
        n/=10;
    }
}
int main() {
    int n,x;
    scanf("%d %d",&n,&x);
    int con=0;
    int *count=&con;
    for(int i=1;i<=n;i++){
        times(i,x,count);
    }
    printf("%d",con);
    return 0;
}