print(sum(map(lambda x:sum((f:=x.count)(c)>f('\n')for c in set(x)),open(0).read()[:-1].split('\n'*2))))