#include <iostream>
using namespace std;
const int n=50;
class reshte
{
char s[50];
char *s;
char x;
int c;
public:
void input();
void calc();
reshte();
void show();
};
void reshte::input()
{
cin.get(s,50);
cin>>x;
}
reshte::reshte()
{
c=0;
}
void reshte::calc()
{
while (*s)
{
if (*s==x)
{
c++;
s++;
}
}
}
void reshte:: show()
{
cout<<c;
}
int main()
{
int i;
reshte myreshte[n];
for (int i=0;i<50;i++)
myreshte[i].input();
myreshte[i].calc();
myreshte[i].show();
}