import datetime,sys for l in sys.stdin:s=map(int,l.split());print(datetime.datetime(s[0],s[1],s[2]).weekday()+1)%7