import time while 1:print-~time.strptime(raw_input(),'%Y %m %d')[6]%7