#include<iostream>
#include<string>
using namespace std;
class Solution{
public:
int numChar(string str, char c){
int count = 0;
for(char s:str){
if(s >= 'a' && s <= 'z'){
if(s == c || s - 32 == c){
count++;
}
}else if(s >= 'A' && s <= 'Z'){
if(s == c || s + 32 == c){
count++;
}
}else{
if(s == c){
count++;
}
}
}
return count;
}
};
int main(){
Solution sol;
string str;
char c;
getline(cin,str);
cin >> c;
cout << sol.numChar(str, c);
return 0;
}
s = input().lower()
c = input().lower()
count = 0
print(s.count(c))