from collections import defaultdict from sys import stdin input = lambda: stdin.readline().rstrip() def main(): S = input() M = int(input()) C = stdin.read().splitlines() strings = defaultdict(list) for i, s in enumerate(S): strings[s].append(i) ans = 0 for ci in C: l = len(ci) for i in strings[ci[0]]: if S[i:i+l] == ci: ans += 1 print(ans) main()