import math import sys import heapq from collections import deque sys.setrecursionlimit(500*500) stdin = sys.stdin def YES(): print('Yes') def NO(): print('No') def TAKAHASHI(): print('Takahashi') def AOKI(): print("Aoki") def ns(): return stdin.readline().strip() def ni(): return int(ns()) def na(): return list(map(int, stdin.readline().split())) def nz(): return list(map(lambda x: int(x)-1, stdin.readline().split())) def nm(n): return [na() for _ in range(n)] MOD = int(1e9+7) def YES(): print('Yes') def NO(): print('No') def TAKAHASHI(): print('Takahashi') def AOKI(): print("Aoki") s = ns() M = ni() s_set = [set()]*11 ans = 0 ord_a = ord('A') def o(s): return ord(s)-ord_a table = {} for i in range(10): for j in range(len(s)-i): if s[j:j+i+1] in table: table[s[j:j+i+1]] += 1 else: table[s[j:j+i+1]] = 1 for i in range(M): c = ns() lc = len(c) hc = 0 hs = 0 if c in table: ans += table[c] print(ans)