import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int x=sc.nextInt(); int ans=0; for(int i=1;i<=n;i++) { int k=i; while(k!=0) { int temp=k%10; if(temp==x) { ans++; } k/=10; } } System.out.println(ans); } }