public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String target = scanner.next();
        char ch = target.toLowerCase().charAt(0);
        char[] arr = str.toLowerCase().toCharArray();
        int res = 0;
        for (int i = 0; i < arr.length; i++) {
            if (ch == arr[i]) {
                res++;
            }
        }
        System.out.println(res);
    }
}