#!/usr/bin/python
import sys
# this example assumes proper dates are entered (there are no safety checks performed)
# split string and convert to integers
month, day, year = map( lambda x: int(x), raw_input().split('/') )
# gregorian?
is_gregorian = True
if (year < 0):
is_gregorian = False
year = year - 1 # account for there being no year zero
else:
from datetime import date
julian_calendar_fail = date(1582, 10, 15) # julian calendar goes away
is_gregorian = date(year, month, day) > julian_calendar_fail
# leap year calculation:
if is_gregorian and year % 4 == 0 and not ( year % 100 == 0 and year % 400 != 0 ):
is_leap_year = True
elif not is_gregorian and year % 4 == 0: # julian
is_leap_year = True
else:
is_leap_year = False
if (month == 2):
days_in_month = 29 if is_leap_year else 28
else:
from calendar import monthrange
days_in_month = monthrange(2000, month) # year irrelevant for non-February months
# safety:
century = int( str(year)[:-2] ) if str(year)[:-2] != '' else 0
year = int( str(year)[-2:] ) if str(year)[-2:] != '' else 0
# the doomsday calculation: http://e...content-available-to-author-only...a.org/wiki/Doomsday_rule
doomsdays = [ 4 if is_leap_year else 3, 29 if is_leap_year else 28, 0, 4, 9, 6, 11, 8, 5, 10, 7, 12 ]
# weekdays, starting with Monday == 0
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
a = year / 12
b = year % 12
c = b / 4
d = ( a + b + c )
# "Finding a year's Doomsday" section @ http://e...content-available-to-author-only...a.org/wiki/Doomsday_rule:
if is_gregorian:
d = d % 7
anchor_days = [ 1, 6, 4, 2 ] # from wikipedia link above
anchor = anchor_days[ century % 4 ]
offset = day - doomsdays[ month - 1 ]
day_of_week = (d + anchor + offset)
else:
anchor = 6 + d - century
anchor += 7 if anchor < 0 else -7 # normalize between -7 and 7
offset = day - doomsdays[ month - 1 ]
day_of_week = (anchor + offset)
# normalize day_of_week to be between 0 and 6
day_of_week = day_of_week % 7
print days[ day_of_week ]
IyEvdXNyL2Jpbi9weXRob24KaW1wb3J0IHN5cwoKIyB0aGlzIGV4YW1wbGUgYXNzdW1lcyBwcm9wZXIgZGF0ZXMgYXJlIGVud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