from collections import Counter S = input() M = int(input()) C = [] for i in range(M): C.append(input()) def search(C, S, flg): count = 0 lenS = len(S) lenC = len(C) if flg == 1: while S.find(C) != -1: S = S[S.find(C)+1:] count += 1 return count else: while S.find(C) != -1: S = S[S.find(C)+lenC:] count += 1 return count count = 0 for i in range(M): CC = C[i] flg = 1 for j in range(len(CC)): if j == 0: continue if CC[j] != CC[j-1]: flg = 0 break count += search(C[i], S, flg) print(count)