import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class ROLLINGHASH: def __init__(self, string, base, mod): self.size = len(string) self.base = base self.mod = mod self.hash = [0]*(self.size + 1) self.pow = [1]*(self.size + 1) for i, c in enumerate(string): o = ord(c) - ord('A') + 1 self.hash[i + 1] = (self.hash[i] * self.base + o) % self.mod self.pow[i + 1] = self.pow[i] * self.base % self.mod def get_hash(self, l, r): """s[l:r]のhash値""" ret = (self.hash[r] - self.hash[l] * self.pow[r - l]) % self.mod return ret def main(): base = 37 mod = 10**9 + 7 S = readline().strip() N = int(readline()) RH = ROLLINGHASH(S, base, mod) ans = 0 for _ in range(N): C = readline().strip() l = len(C) rh = ROLLINGHASH(C, base, mod).hash[l] for i in range(len(S) - l + 1): if rh == RH.get_hash(i, i + l): ans += 1 print(ans) if __name__ == "__main__": main()