#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a-1) ; i>=(b);i--)
#define rep(i,n) FOR(i,0,n)
#define PB push_back
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FILL(a, value) memset(a, value, sizeof(a))
typedef long long LL ;
typedef vector<int > VI ;
typedef vector<LL > VL;
typedef pair<int,int > PII;
const LL LINF = 1e18 +47;
const int INF = 1e9 +47 ;
const int MOD = 1e9 + 7;
const int modulo = 1e8 ;
const int nax = 51;
const double EPS = 1e-7;
const int MAX = 100*1000 + 47;
struct automaton
{
struct node
{
int g[26];
int link, len;
int cnt;
void init()
{
FILL(g, -1);
link = len = -1;
cnt = 1;
}
} A[MAX * 2];
int sz, head;
void init()
{
sz = 1; head = 0;
A[0].init();
A[0].cnt = 0;
}
void add(char ch)
{
ch = ch - 'a';
int nhead = sz++;
A[nhead].init();
A[nhead].len = A[head].len + 1;
int cur = head;
head = nhead;
while(cur != -1 && A[cur].g[ch] == -1)
{
A[cur].g[ch] = head;
cur = A[cur].link;
}
if (cur == -1)
{
A[head].link = 0;
return ;
}
int p = A[cur].g[ch];
if (A[p].len == A[cur].len + 1)
{
A[head].link = p;
return ;
}
int q = sz++;
A[q] = A[p];
A[q].cnt = 0;
A[q].len = A[cur].len + 1;
A[p].link = A[head].link = q;
while(cur != -1 && A[cur].g[ch] == p)
{
A[cur].g[ch] = q;
cur = A[cur].link;
}
}
vector<int> g[2 * MAX];
void calcCnt() {
FOR(i, 1, sz) g[A[i].link].PB(i);
_calcCnt(0);
}
int _calcCnt(int v) {
FOR(i, 0, SZ(g[v]))
A[v].cnt += _calcCnt(g[v][i]);
return A[v].cnt;
}
} A;
char S[MAX];
int main() {
scanf("%s", S);
int n = strlen(S);
A.init();
FOR(i, 0, n) A.add(S[i]);
A.calcCnt();
int m;
scanf("%d", &m);
long long ans = 0;
FOR(i, 0, m) {
scanf("%s", S);
int s = strlen(S);
int v = 0;
FOR(j, 0, s) {
int nxt = A.A[v].g[S[j]-'a'];
if (nxt == -1) break;
v = nxt;
ans += A.A[v].cnt;
}
}
cout << ans << endl;
return 0;
}