groups = open("input", "r").read().split("\n\n") people = [[set(p) for p in g.split("\n") if p] for g in groups] common = [p[0].intersection(*p) for p in people] print(sum([len(c) for c in common]))