#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    char a;
    cin>>s;
    cin>>a;
    int sum = 0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]==a||s[i]==(a+32)||s[i]==(a-32))
            sum++;
    }
    cout<<sum;
    return 0;
}