#!/usr/bin/env pypy3 import re def count_all(s, substr): ptn = re.compile("(?={})".format(substr)) return sum(1 for m in re.finditer(ptn, s)) def main(): s = input() m = int(input()) cs = [input() for _ in range(m)] print(sum(count_all(s, c) for c in cs)) if __name__ == '__main__': main()