while 1: Q=1;R=B=N=2;p=9 for c in input():exec(c+"-=1;p-=0>"+c) print(+(p>0))