S = input() M = int(input()) s = set() for _ in range(M): C = input() s.add(C) ans = 0 for i in range(1,11): for j in range(len(S) - i+1): if S[j:j+i] in s: ans += 1 print(ans)