u=lambda x:6=0,'ec':lambda x:x in'ambblubrngrygrnhzloth','pi':lambda x:len(x)==9,'ci':lambda x:0}[y[:2]](y[4:]),x)) print(sum(map(lambda x:u(x.split()),open("/dev/stdin").read().split("\n\n"))))