#include <string.h>
#include <stdio.h>
int main(){
char str[1000];
char key;
scanf("%[^\n]",&str);
scanf(" %c",&key);
int len = strlen(str);
int count = 0;
if ((key>= 48)&&(key<=57)){
for (int i = 0; i < len; i++) {
if (str[i] == key){
count++;
}
}
} else {
for (int i = 0; i < len; i++) {
if (str[i] == key || str[i] == key+32 || str[i]+32 == key){
count++;
}
}
}
printf("%d\n",count);
}