#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define re(i, n) for (int i=0; i<n; i++)
#define re1(i, n) for (int i=1; i<=n; i++)
#define re2(i, l, r) for (int i=l; i<r; i++)
#define re3(i, l, r) for (int i=l; i<=r; i++)
#define rre(i, n) for (int i=n-1; i>=0; i--)
#define rre1(i, n) for (int i=n; i>0; i--)
#define rre2(i, r, l) for (int i=r-1; i>=l; i--)
#define rre3(i, r, l) for (int i=r; i>=l; i--)
#define ll long long
#define root 1
const int MAXN = 300010, MAXS = 4000000, INF = ~0U >> 2;
struct node {
bool FF;
int KK, fail, ch[26];
} T[MAXS];
struct sss {
int l, r;
bool operator< (sss s0) const {return l < s0.l || l == s0.l && r < s0.r;}
} A[MAXN];
int n, S, Q[MAXS], res = 0;
char ss[MAXN], ss0[MAXN];
void ins()
{
int len = strlen(ss0), x = root, c;
re(i, len) {
c = ss0[i] - 97;
if (!T[x].ch[c]) {T[x].ch[c] = ++S;}
x = T[x].ch[c];
}
T[x].FF = 1; T[x].KK = len;
}
void init()
{
scanf("%d%s", &n, ss); S = 1;
int m0; scanf("%d", &m0);
re(i, m0) {
scanf("%s", ss0); ins();
}
}
void prepare()
{
Q[0] = root; T[root].fail = 0; int i, j, x;
for (int front=0, rear=0; front<=rear; front++) {
i = Q[front];
re(k, 26) if (j = T[i].ch[k]) {
x = T[i].fail;
while (x && !T[x].ch[k]) x = T[x].fail;
if (T[x].ch[k]) x = T[x].ch[k]; else x = root;
T[j].fail = x; if (T[x].FF && !T[j].FF) {T[j].FF = 1; T[j].KK = T[x].KK;}
Q[++rear] = j;
}
}
}
void solve()
{
int x = root, c, n0 = 0;
re(i, n) {
c = ss[i] - 97;
while (x && !T[x].ch[c]) x = T[x].fail;
if (T[x].ch[c]) x = T[x].ch[c]; else x = root;
if (T[x].FF) {A[n0].l = i - T[x].KK + 1; A[n0++].r = i;}
}
sort(A, A + n0); int maxr;
if (n0) {
if (A[0].l) res = A[0].l; maxr = A[0].r;
re2(i, 1, n0) {
if (A[i].l > maxr + 1) res += A[i].l - maxr - 1;
if (A[i].r > maxr) maxr = A[i].r;
}
if (maxr < n - 1) res += n - maxr - 1;
} else res = n;
}
void pri()
{
printf("%d\n", res);
}
int main()
{
init();
prepare();
solve();
pri();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgcmUoaSwgbikgZm9yIChpbnQgaT0wOyBpPG47IGkrKykKI2RlZmluZSByZTEoaSwgbikgZm9yIChpbnQgaT0xOyBpPD1uOyBpKyspCiNkZWZpbmUgcmUyKGksIGwsIHIpIGZvciAoaW50IGk9bDsgaTxyOyBpKyspCiNkZWZpbmUgcmUzKGksIGwsIHIpIGZvciAoaW50IGk9bDsgaTw9cjsgaSsrKQojZGVmaW5lIHJyZShpLCBuKSBmb3IgKGludCBpPW4tMTsgaT49MDsgaS0tKQojZGVmaW5lIHJyZTEoaSwgbikgZm9yIChpbnQgaT1uOyBpPjA7IGktLSkKI2RlZmluZSBycmUyKGksIHIsIGwpIGZvciAoaW50IGk9ci0xOyBpPj1sOyBpLS0pCiNkZWZpbmUgcnJlMyhpLCByLCBsKSBmb3IgKGludCBpPXI7IGk+PWw7IGktLSkKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSByb290IDEKY29uc3QgaW50IE1BWE4gPSAzMDAwMTAsIE1BWFMgPSA0MDAwMDAwLCBJTkYgPSB+MFUgPj4gMjsKc3RydWN0IG5vZGUgewoJYm9vbCBGRjsKCWludCBLSywgZmFpbCwgY2hbMjZdOwp9IFRbTUFYU107CnN0cnVjdCBzc3MgewoJaW50IGwsIHI7Cglib29sIG9wZXJhdG9yPCAoc3NzIHMwKSBjb25zdCB7c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