#include<iostream>
using namespace std;

int main(){
    string input;
    char target;
    int times = 0;
    getline(cin, input);
    cin>>target;
    
    for(auto c: input){
        if(c == target || toupper(c) == target || tolower(c) ==  target){
            times++;
        } 
    }
    cout<<times<<endl;
    return 0;
}