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

int main() {
    string str;
    char c;
    while (getline(cin,str) && cin>>c) 
    { 
        size_t res=0;
        char tmp=c;
        if(c>='a'&& c<='z') {
            tmp=c-32;
        }
        else if(c>='A' && c<='Z'){
            tmp=c+32;
        }
        for(size_t i=0;i<str.size();i++)
        {
            
            if(str[i]==c||str[i]==tmp) {
                res++;
            }
        }
        cout << res << endl;
    }
}