x=lambda a:+(len(a)<=2*sum(i if i<2 else x(i)for i in a)) while 1:print x(eval("".join(["0,","1,","[","],"]["01{}".find(c)]for c in raw_input()))[0])