S = input().strip() M = int(input()) C = [input().strip() for _ in range(M)] from collections import defaultdict count_map = defaultdict(int) n = len(S) for i in range(n): max_j = min(10, n - i) for j in range(1, max_j + 1): substr = S[i:i+j] count_map[substr] += 1 total = 0 for c in C: total += count_map.get(c, 0) print(total)