r=io.read f=math.floor while''do y=r(4)m=r'*n'if m<3 then m=m+12 y=y-1 end print(f(y+f(y/4)-f(y/100)+f(y/400)+2.6*m+1.6+r())%7)end