#include<bits/stdc++.h>
#define add_SUU ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
#define inf 0x3f3f3f3f
#define x first
#define y second
#define int long long
#define iter set<pii>::iterator
using namespace std;
typedef pair<int,int> pii;
const int maxn=5e5+1000;
int tot,cnt,idx;
//int vis[10000];
int MOD=1e9+7;
//vector<vector<int>>G(maxn);
map<string,int>vis;
void work(){
int n,m,k;
cin>>n;
for(int i=1;i<=n;i++){
string s;
cin>>s;
vis[s]++;
}
string tmp="",s;
cin>>s;
for(char ch:s){
tmp+=ch;
if(vis.count(tmp))tot+=vis[tmp];
}
cout<<tot<<'\n';
}
signed main()
{
add_SUU;
int t=1;
// cin>>t;
while(t--)
work();
return 0;
}