import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class KMP(): def __init__(self, pattern): n = len(pattern) table = [0]*(n + 1) table[0], table[1] = -1, 0 i, j = 2, 0 while i <= n: if pattern[i - 1] == pattern[j]: table[i] = j + 1 i += 1; j += 1 elif j > 0: j = table[j] else: table[i] = 0 i += 1 self.size = n self.pattern = pattern self.table = table def search(self, text): l = len(text) n = self.size table = self.table pattern = self.pattern m, i = 0, 0 ret = 0 while m + i < l: if pattern[i] == text[m + i]: i += 1 if i == n: ret += 1 m += i - table[i] i = table[i] else: m += i - table[i] if i > 0: i = table[i] return ret def main(): S = readline().strip() N = int(readline()) ans = 0 for _ in range(N): kmp = KMP(readline().strip()) ans += kmp.search(S) print(ans) if __name__ == "__main__": main()