#include<bits/stdc++.h>
using namespace std;
struct ll{int ch[30];}tre[1000005];
int num[3000000],tot,cnt[3000000];
inline void trie(string st,int k){
int u=0;
for(int i=0;i<st.size();i++){
int c=st[i]-'a'+1;
if(!tre[u].ch[c])tre[u].ch[c]=++tot;
u=tre[u].ch[c];
}
num[u]++;
}
int fail[3000000];
void get_fail(){
queue<int>q;
for(int i=1;i<=26;i++){
int v=tre[0].ch[i];
if(v){
q.push(v);
fail[v]=0;
}
}
while(!q.empty()){
int u=q.front();
q.pop();
for(int i=1;i<=26;i++){
int v=tre[u].ch[i];
if(v){
fail[v]=tre[fail[u]].ch[i];
q.push(v);
}
else tre[u].ch[i]=tre[fail[u]].ch[i];
}
}
}
int ans,s[3000000];
void get_ans(string st){
for(int i=0;i<st.size();i++){
int u=tre[u].ch[st[i]-'a'+1];
for(int j=u;j;j=fail[j]){
ans+=num[j];
num[j]=0;
}
}
}
int n;
string t,st;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>t;
trie(t,i);
}
get_fail();
cin>>st;
get_ans(st);
cout<<ans;
return 0;
}