#include<iostream>
#include<string>
using namespace std;
int main() {
    string str;
     int res = 0;
    while (getline(cin, str)) {
        char c;
        cin >> c;
        bool isUpper = false;
        isUpper = (int)c >= 97 ? false : true;
        for (int i = 0; i < str.size(); i++) {
            if (isUpper) {
                if (str[i] == c || (str[i] - 32 == int(c))) {
                    res++;
                }
            }
            else {
                if (str[i] == c || (str[i] + 31 == int(c))) {
                    res++;
                }
            }
        }
    }
    cout << res << endl;
}