#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
getline(cin, s);
char c;
cin >> c;
int L = s.length(), k = 0;
for(int i = 0; i < L; i++){
if(s[i] == c || s[i] == c - 32)k++;
}
cout << k;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglzdHJpbmcgczsKCWdldGxpbmUoY2luLCBzKTsKCWNoYXIgYzsKCWNpbiA+PiBjOwoJaW50IEwgPSBzLmxlbmd0aCgpLCBrID0gMDsKCWZvcihpbnQgaSA9IDA7IGkgPCBMOyBpKyspewoJCWlmKHNbaV0gPT0gYyB8fCBzW2ldID09IGMgLSAzMilrKys7Cgl9Cgljb3V0IDw8IGs7CglyZXR1cm4gMDsKfQ==