import sys from collections import defaultdict 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() M = int(readline()) L = len(S) RH = ROLLINGHASH(S, base, mod) d = defaultdict(int) for length in range(1, 11): for l in range(L - length + 1): r = l + length h = RH.get_hash(l, r) d[h] += 1 ans = 0 for _ in range(M): C = input() h = ROLLINGHASH(C, base, mod).hash[len(C)] ans += d[h] print(ans) if __name__ == "__main__": main()