def solve(): s = input() slist = [] slen = len(s) for i in range(1, 11): if i <= slen: for j in range(slen-i+1): slist.append(s[j:j+i]) ans = 0 for i in range(int(input())): ans += slist.count(input()) print(ans) if __name__=="__main__": solve()