package com.thinker.bishi.huawei;

import java.util.Scanner;

public class CountCharNum{

	public static int count(String s1,char s2){
		if(s1 == null || "".equals(s1)) return 0;
		int count = 0;
		int flag = 0;
		if((int)s2 >= 65 && (int)s2 <= 90)flag = 1;
		if((int)s2 >= 97 && (int)s2 <= 122) flag = 2;
		for(int i=0;i<s1.length();i++){
			if(s2 == s1.charAt(i))count ++;	
			if(flag == 1){
				if((char)(s2+32) == s1.charAt(i)) count ++;
			} 
			if(flag == 2){
				if((char)(s2-32) == s1.charAt(i)) count ++;
			}

		}
		return count;
	}

	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String s1 = in.nextLine();
		char s2 = ' ';
		if(in.hasNextLine()){
			s2 = in.nextLine().charAt(0);
		}
		System.out.println(count(s1,s2));
	}
}
