#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e6+10;
const int maxm=1e4+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int trie[maxn][26],fail[maxn],e[maxn],cnt=0,n;
string s[maxn],ss;
void insert(string x){
int now=0;
rep(i,0,x.size()){
int tmp=x[i]-'a';
if(!trie[now][tmp]) trie[now][tmp]=++cnt;
now=trie[now][tmp];
}
e[now]++;
}
queue<int> q;
void bfs(){
while(!q.empty()) q.pop();
rep(i,0,26) if(trie[0][i]) q.push(trie[0][i]);
while(!q.empty()){
int tp=q.front();q.pop();
rep(i,0,26){
if(trie[tp][i]) fail[trie[tp][i]]=trie[fail[tp]][i],q.push(trie[tp][i]);
else trie[tp][i]=trie[fail[tp]][i];
}
}
}
int ans=0;
int query(string x){
int cur=0;
rep(i,0,x.size()){
int tmp=x[i]-'a';
cur=trie[cur][tmp];
for(int j=cur;j&&e[j]!=-1;j=fail[j])
ans+=e[j],e[j]=-1;
}
return ans;
}
int main(){/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
ans=cnt=0;
///mst(trie,0),mst(e,0);
cin>>n;
rep(i,0,n){
cin>>s[i];
insert(s[i]);
}
bfs();
cin>>ss;
cout<<query(ss)<<"\n";
return 0;
}