S = input() M = int(input()) D = {input() for _ in range(M)} print(sum(S[j:j+i] in D for i in range(1, 11) for j in range(len(S) - i + 1)))