import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
Scanner s = new Scanner(System.in);
int d = s.nextInt();
int c = 0;
for (int i = n; i >=1; i = i / 10) {
if (i % 10== d)
c++;
}
System.out.println©;
}
}