#include<iostream>
#include<string>
using namespace std;
//!!!不区分大小写,所以进行ascll码+32一样也++
int main()
{
    string str;
    char s;
    int count=0;
    cin>>str;
    cin>>s;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]==s)
        {
            count++;
        }  
        else if(str[i]+32==s)
        {
            count++;
        } 
    }
    cout<<count<<endl;
 return 0;   

}