from math import * from heapq import * from bisect import * from copy import * from random import * from collections import * from itertools import * from decimal import * #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import * #@lru_cache(maxsize=None) from operator import * from sys import * input = stdin.readline # .rstrip() INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!! ''' これO(S^2)が通らんのしんどくね C++用なんかな 部分文字列か まあ主客転倒的なあれだな 部分文字列って連続かよ ''' S = list(input().rstrip()) N = len(S) M = int(input()) memo = defaultdict(int) for i in range(N): s = [] for j in range(1,11): k = i+j-1 if k >= N: break s.append(S[k]) memo[''.join(s)] += 1 ans = 0 for _ in range(M): C = input().rstrip() ans += memo[C] print(ans)