result = 0 S = input() M = int(input()) i = 1 while i <= M: C = input() result = result + S.count(C) i += 1 print(result)