import java.util.Scanner;

public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String input = sc.nextLine(); String symbol = sc.nextLine(); String str = input.toLowerCase(); char c = symbol.toLowerCase().charAt(0); int count = 0; for (int i = 0; i < str.length(); i++) { if (c == str.charAt(i)) { count++; } } System.out.println(count); } }