#include #include #include #define F 26 typedef struct trieNode{ int cnt; struct trieNode *next[F]; } trie; trie *newNode(void){ trie *res=(trie *)malloc(sizeof(trie)); res->cnt=0; int i; for(i=0;inext[i]=NULL; return res; } trie *add(trie *r,char *s){ if(r==NULL) r=newNode(); if(*s=='\0'){ r->cnt++; } else { r->next[*s-'A']=add(r->next[*s-'A'],s+1); } return r; } void run(void){ char *s=(char *)malloc(sizeof(char)*(50000+1)); scanf("%s",s); int m; scanf("%d",&m); trie *root=NULL; while(m--){ char c[11]; scanf("%s",c); root=add(root,c); } int slen=strlen(s); int ans=0; int i; for(i=0;icnt; if(knext[s[k]-'A']; k++; } } printf("%d\n",ans); } int main(void){ run(); return 0; }