import math

leap_normal = input()
p = int(input())
h = int(input())

weekends = 48

weekends_in_sofia = weekends - h
saturday_gam_in_sofia = weekends_in_sofia * 0.75
sunday_in_h = h
games_in_sofia_P = p * 2/3
total_games = saturday_gam_in_sofia + sunday_in_h + games_in_sofia_P

if leap_normal == "leap":
    total_games = total_games * 1.15


print(math.floor(total_games))
