import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            String str = scanner.nextLine().toLowerCase();
            String checkChar = scanner.nextLine().toLowerCase();
            //方法一:通过replaceAll匹配待检查的字符,返回剩余的字符串,用原长度减去剩余长度就是该字符出现的次数
            System.out.print(str.length()-str.replaceAll(checkChar,"").length());
            //方法二:将输入字符串转成List,遍历List的同时判断检查字符是否与list元素有重复的,有则记录count
//             int count = 0;
//             List<String> strList = Arrays.asList(str.split(""));
//             for(String k : strList){
//                 if(checkChar.equals(k))
//                     count++;
//             }
//             System.out.print(count);
            
        }
        
    }
}