c={r[:i]:r[i+2:].split()for r in open(0)if(i:=r.find(': '))};print((p:=lambda n:sum(p(c)for c in c[n])if n!="out"else 1)("you"))