#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
struct tire
{
struct tire*next[26];
int num;
tire()
{
for( int i = 0; i<26; i++)
next[i] = NULL;
num = 0;
};
}root;
void insert( char *s)
{
int len = strlen(s);
tire *p = &root;
for( int i =0 ;i < len; i++)
{
if( p->next[s[i]-'a'] == NULL)
p->next[s[i] - 'a'] = new tire;
p = p->next[s[i] -'a'];
p->num++;
}
//cout<<"S"<<endl;
}
int find(char *s)
{
tire *p = &root;
int len = strlen(s);
for( int i = 0; i<len; i++)
{
if(p->next[s[i]-'a'] == NULL)
return 0;
else
{
p = p->next[s[i]-'a'];
}
}
return p->num;
}
int main()
{
char str[11];
while(gets(str) && str[0] != '\0')
insert(str);
while(~scanf("%s",str))
printf("%d\n",find(str));
}#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
struct tire
{
struct tire*next[26];
int num;
tire()
{
for( int i = 0; i<26; i++)
next[i] = NULL;
num = 0;
};
}root;
void insert( char *s)
{
int len = strlen(s);
tire *p = &root;
for( int i =0 ;i < len; i++)
{
if( p->next[s[i]-'a'] == NULL)
p->next[s[i] - 'a'] = new tire;
p = p->next[s[i] -'a'];
p->num++;
}
//cout<<"S"<<endl;
}
int find(char *s)
{
tire *p = &root;
int len = strlen(s);
for( int i = 0; i<len; i++)
{
if(p->next[s[i]-'a'] == NULL)
return 0;
else
{
p = p->next[s[i]-'a'];
}
}
return p->num;
}
int main()
{
char str[11];
while(gets(str) && str[0] != '\0')
insert(str);
while(~scanf("%s",str))
printf("%d\n",find(str));
}