import sys input = sys.stdin.readline def make_table(s): n = len(s) res = [-1]*(n+1) j = -1 for i in range(n): while j>=0 and s[i]!=s[j]: j = res[j] j += 1 res[i+1] = j return res def kmp(s, w): #s中のwと一致する箇所の先頭インデックスのリストを作成 #table = make_table(w) res = [] m, i, n = 0, 0, len(s) while m+i0: i = table[i] return res S = input()[:-1] M = int(input()) table = make_table(S) ans = 0 for _ in range(M): C = input()[:-1] ans += len(kmp(S, C)) print(ans)