http://code.bupt.edu.cn/problem/p/99/
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
for(int k=1;k<=n;k++)
{
char ch;
getchar();
scanf("%c",&ch);
string s;
char ss[1001];
getchar();
scanf("%s",ss);
s=ss;
int num=0;
int len=s.length();
for(int i=0;i<len;i++)
if(s[i]==ch)
num++;
printf("%d\n",num);
}
return 0;
}