from collections import defaultdict def get_input(): s = str(input()) m = int(input()) c = [str(input()) for i in range(m)] return s, m, c if __name__ == "__main__": s, m, c = get_input() count = 0 s_id = defaultdict(lambda:len(s_id)+1) for ci in c: len_c = len(ci) first, target = 0, 0 for i in range(len_c): target += s_id[ci[i]] * (len(s_id)+1)**(len_c - i - 1) first += s_id[s[i]] * (len(s_id)+1)**(len_c - i - 1) for i in range(len_c,len(s)): if first == target: count += 1 first = (first % (len(s_id)+1)**(len_c -1 )) * (len(s_id)+1) + s_id[s[i]] if target == first: count += 1 print(count)