#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main()
{

    string s;
    getline(cin, s);
    std::transform(s.begin(), s.end(), s.begin(), ::tolower);

    map<char, int> count;
    char symbol;
    cin >> symbol;
    symbol = tolower(symbol);
    for (auto c : s)
    {
        count[c]++;
    }
    cout<<count[symbol];
    return 0;
}