weekday=["Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday"]
days=0
m_day=[31,28,31,30,31,30,31,31,30,31,30,31]
for i in range(2020):
    if i%400 or (i%4==0 and i%100!=0):
        days+=366
    else:
        days+=365
for k in range(11):
    days+=m_day[k]
t_days=days+18+1     #2020-11-18
print(t_days%7)
dict_1={2:"Sunday",3:"Monday",4:"Tuesday",5:"Wednesday",6:"Thursday", 0:"Friday",1:"Saturday"}
dict_2={-5:"Sunday",-4:"Monday",-3:"Tuesday",-2:"Wednesday",-1:"Thursday", 0:"Friday",-6:"Saturday"}
total_day=0
year,month,day=map(int,input().split())
if month<1 or month>12:
    print("Illegal")
elif day>m_day[month-1] or day<1:
    print("Illegal")
elif year%400 or (year%4==0 and year%100!=0):
        if  month==2 and (day>29 or day<1):
            print("Illegal")    
        else:
            for i in range(month):
                total_day+=m_day[month]
else:
        for i in range(month):
                total_day+=m_day[month]
print(total_day+day)