S = input() l = len(S) #Sから作れる部分文字列を全列挙。 s = [] for i in range(l): for j in range(1, 11): if i +j <= l: s.append(S[i:i+j]) import collections s = collections.Counter(s) m = int(input()) ans = 0 for _ in range(m): c = input() ans += s[c] print(ans)