import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
str = str.toUpperCase();
String c = sc.nextLine();
c = c.toUpperCase();
String[] arr = str.split("");
HashMap<String,Integer> hashMap = new HashMap<>();
for(int i = 0 ; i<arr.length ; i++){
Integer count = hashMap.get(arr[i]);
if(count == null){
count = 1;
}else{
count += 1;
}
hashMap.put(arr[i],count);
}
Integer out = hashMap.get(c);
if(out == null){
out = 0;
}
System.out.println(out);
}
}