#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    while (getline(cin, s)) {
        char c;
        cin >> c;
        c = tolower(c);
        int n = s.size();
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (tolower(s[i]) == c) {
                ++cnt;
            }
        }
        cout << cnt << endl;
        getchar();
    }
}
// 64 位输出请用 printf("%lld")