from datetime import datetime as d while True:print (d(*map(int,raw_input().split())).weekday()+1)%7