def roll_hash(mojiretus): alpha2num = lambda c: ord(c) - ord('A') + 1 base_num = 27 hash = 0 for i, moji in enumerate(mojiretus[::-1]): hash += alpha2num(moji) * (base_num**i) return hash def main(): S = input() M = int(input()) C = [] for _ in range(M): C.append(input()) S_len = len(S) ans = 0 for Ci in C: gold = roll_hash(Ci) Ci_len = len(Ci) for i in range(S_len - Ci_len + 1): if roll_hash(S[i:i+Ci_len]) == gold: ans += 1 print(ans) if __name__ == '__main__': main()