def counter(s: str, t: str) -> int: m = 0 while True: if t not in s: break i = s.index(t) if t in s[i:]: m += 1 s = s[i+1:] return m s = input() print(sum( counter(s, t) if t in s else 0 for t in [input() for _ in range(int(input()))] ) )