#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;

int main() {
    string s;
    getline(cin,s);
    char c;
    cin >> c;
    unordered_map<char,int> mp;
    for (char ch:s){
        if (tolower(ch)==tolower(c))
            mp[c]++;
    } 
    cout << mp[c] << endl;
}