#include <bits/stdc++.h>
using namespace std;
const int M = 1e6 + 10;
const int N = 128;
int n;
int tr[M][N], nex[M], cnt[M];
int q[M], hh , tt = -1;
char str[M];
int idx, res;
bool st[M];
void Insert()
{
int p = 0;
for(int i = 0; str[i]; i++)
{
int t = str[i];
if(!tr[p][t]) tr[p][t] = ++idx;
p = tr[p][t];
}
cnt[p]++;
}
void init()
{
memset(tr, 0, sizeof tr);
memset(nex, 0, sizeof nex);
memset(cnt, 0, sizeof cnt);
idx = res = 0;
}
void bulid()
{
int hh = 0, tt = -1;
for(int i = 0; i < N; i++)
if(tr[0][i]) q[++tt] = tr[0][i];
while(hh <= tt)
{
int t = q[hh++];
for(int i = 0; i < N; i++)
{
int p = tr[t][i];
if(!p) tr[t][i] = tr[nex[t]][i];
else
{
nex[p] = tr[nex[t]][i];
q[++tt] = p;
}
}
}
}
int main()
{
init();
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%s", str);
Insert();
}
bulid();
scanf("%s", str);
for(int i = 0, j = 0; str[i]; i++)
{
int t = str[i];
j = tr[j][t];
int p = j;
while(p && st[p] == 0)
{
st[p] = 1;
res += cnt[p];
cnt[p] = 0;
p = nex[p];
}
}
printf("%d\n", res);
return 0;
}