while 1: s=input() for x in"QRRBBNN":s=s.replace(x,'',1) print(1*(len(s)<9))