package startingwithjav;
import java.util.Scanner;
public class count {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int num=scn.nextInt();
Scanner sc=new Scanner(System.in);
int d=sc.nextInt();
int count=0;
while(num>0)
{
if (num%10==d)
count++;
num=num/10;
}
System.out.print(count);
}
}