#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "< P; struct node { node *nxt[30]; bool hit; node(){ REP(i,30)nxt[i]=NULL; hit = false; } }; char s[52525]; int m; char c[5252][25]; int main(){ scanf("%s",s); scanf("%d",&m); REP(i,m)scanf("%s",c[i]); node *root = new node(); REP(i,m){ node *cur = root; REP(j,strlen(c[i])){ int id = c[i][j]-'A'+1; if(cur->nxt[id] == NULL)cur->nxt[id] = new node(); cur=cur->nxt[id]; } cur->hit = true; } int n = strlen(s); int ans = 0; REP(i,n){ node *cur = root; int j = i; while(jnxt[id]==NULL)break; cur=cur->nxt[id]; if(cur->hit)++ans; ++j; } } printf("%d\n",ans); return 0; }