public class Main {
public int solution(String str, char c) {
int answer = 0;
String s = str.toUpperCase();
char c1 = Character.toUpperCase(c);
for (char data: s.toCharArray()) {
if (data == c1) {
answer++;
}
}
return answer;
}
public static void main(String[] args) {
Main T = new Main();
Scanner sc = new Scanner(System.in);
String str = sc.next();
char c = sc.next().charAt(0);
System.out.println(T.solution(str, c));
}
}