s = input() m = int(input()) h = {} mx = 0 for _ in range(m): c = input() h[c] = True mx = max(len(c), mx) ans = 0 for i in range(len(s)): for j in range(1, mx + 1): if s[i : i + j] in h: ans += 1 print(ans)