from collections import defaultdict def rolling_hash(s: str): """[l, r] のハッシュを返す関数を返す""" mod = 998244353 p = 1009 n = len(s) t = [ord(c) for c in s] a = [0] * n b = [0] * n a[0] = t[0] b[0] = 1 for i in range(1, n): a[i] = (a[i-1] * p + t[i]) % mod b[i] = (p * b[i-1]) % mod # [l, r] のハッシュ値 def f(l: int, r: int) -> int: assert 0 <= l <= r < n h = a[r] if l > 0: h -= a[l-1] * b[r-l+1] h %= mod return h return f S = input() hash = rolling_hash(S) d = defaultdict(int) for i in range(1, 11): for j in range(len(S)): if j+i > len(S): break h = hash(j, j+i-1) d[h] += 1 ans = 0 M = int(input()) for _ in range(M): C = input() ha = rolling_hash(C) h = ha(0, len(C)-1) ans += d[h] print(ans)