def search(C, S): count = 0 while S.find(C) != -1: S = S[S.find(C)+1:] count += 1 return count S = input() M = int(input()) count = 0 for i in range(M): count += search(input(), S) print(count)