import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int d = sc.nextInt();
System.out.println(countDigit(n,d));
}
public static int countDigit(int n,int d){
int count = 0;
while(n !=0){
int rem = n%10;
if(rem == d){
count++;
}
n = n/10;
}
}
}