import re s=input() n=int(input()) c=0 for _ in [0]*n: c+=len(re.findall('(?='+input()+')',s)) print(c)