Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.Limak wants to prove how responsible a bear he is. He is going to regularly save candies for the entire year 2016! He considers various saving plans. He can save one candy either on some fixed day of the week or on some fixed day of the month.Limak chose one particular plan. He isn't sure how many candies he will save in the 2016 with his plan. Please, calculate it and tell him.

The only line of the input is in one of the following two formats:    "x of week" where x (1 ≤ x ≤ 7) denotes the day of the week. The 1-st day is Monday and the 7-th one is Sunday.  "x of month" where x (1 ≤ x ≤ 31) denotes the day of the month.

Print one integer — the number of candies Limak will save in the year 2016.

NotePolar bears use the Gregorian calendar. It is the most common calendar and you likely use it too. You can read about it on Wikipedia if you want to – https://en.wikipedia.org/wiki/Gregorian_calendar. The week starts with Monday.In the first sample Limak wants to save one candy on each Thursday (the 4-th day of the week). There are 52 Thursdays in the 2016. Thus, he will save 52 candies in total.In the second sample Limak wants to save one candy on the 30-th day of each month. There is the 30-th day in exactly 11 months in the 2016 — all months but February. It means that Limak will save 11 candies in total.

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    t = LS()
    n = int(t[0])
    if t[-1] == 'week':
        if n in [5,6]:
            return 53
        return 52

    if n < 30:
        return 12
    if n == 30:
        return 11
    return 7

print(main())

s = input()
x = int(s[0:2])
if 'week' in s:
    if 5 <= x <= 6:
        print(53)
    else:
        print(52)

else:
    if x == 30:
        print(11)
    elif x == 31:
        print(7)
    else:
        print(12)

n = input()
x = int(n[0])
a = x
i = 5
if n[1] != ' ':
    y = int(n[1])
    a = x * 10 + y
    i += 1
else:
    y = 0

if n[i] == 'w':
    if x == 5 or x == 6:
        print(53)
    else:
        print(52)
else:
    if a <= 29:
        print(12)
    elif a == 30:
        print(11)
    elif a == 31:
        print(7)

import math

n, a, b = [str(i) for i in input().split()]
n = int(n)

def calc(n):
    if(n == 5):
        if(365/7 > int(math.trunc(365/7))):
            print(math.trunc(365/7)+1)
        else:
            print(math.trunc(365/7))
    elif(n == 6):
        if(364/7 > int(math.trunc(364/7))):
            print(math.trunc(364/7)+1)
        else:
            print(math.trunc(364/7)+1)
    elif(n == 7):
        if(363/7 > int(math.trunc(363/7))):
            print(math.trunc(363/7)+1)
        else:
            print(math.trunc(363/7))
    elif(n == 1):
        if(362/7 > int(math.trunc(362/7))):
            print(math.trunc(362/7)+1)
        else:
            print(math.trunc(362/7))
    elif(n == 2):
        if(361/7 > int(math.trunc(361/7))):
            print(math.trunc(361/7)+1)
        else:
            print(math.trunc(361/7))
    elif(n == 3):
        if(360/7 > int(math.trunc(360/7))):
            print(math.trunc(360/7)+1)
        else:
            print(math.trunc(360/7))
    elif(n == 4):
        if(359/7 > int(math.trunc(359/7))):
            print(math.trunc(359/7)+1)
        else:
            print(math.trunc(359/7))

if (b == "month"):
    if(n <= 29):
        print(12)
    elif(n == 30):
        print(11)
    else:
        print(7)
else:
    calc(n)

from operator import itemgetter
#int(input())
#map(int,input().split())
#[list(map(int,input().split())) for i in range(q)]
#print("YES" * ans + "NO" * (1-ans))
s = input().split()
if len(s[2]) == 5:
    if s[0] == "30":
        print(11)
    elif s[0] == "31":
        print(7)
    else:
        print(12)
else:
    if s[0] == "6" or s[0] == "5" :
        print(53)
    else:
        print(52)

a = input().strip().split()
i = int(a[0])
if a[-1] == 'month':
  if i <= 29:
    print(12)
  elif i == 30:
    print(11)
  else:
    print(7)
else:
  if i == 5 or i == 6:
    print(53)
  else:
    print(52)

str = raw_input()
str = str.split()
date = str[0]
if str[2] == "week":
    if date == '5' or date == '6':
        print 53;
    else :
        print 52;
else :
    if date == '31':
        print 7;
    elif date == '30':
        print 11;
    else :
        print 12;

n=input().split()
if("week" in n):
	if("6" in n or "5" in n):
		print(53)
	else:
		print(52)
else:
	if("30" in n):
		print(11)
	elif("31" in n):
		print(7)
	else:
		print(12)

from sys import stdin
x,y,z = stdin.readline().strip().split()
x=int(x)
if z=="month":
 if x<=29:
  print 12
 elif x==30:
  print 11
 else:
  print 7
else:
 we = [0,52,52,52,52,53,53,52,52,52,52,52]
 print we[x]

a,b,c = input().split()
a = int (a)

if c[0]=='m':
    if a>=1 and a<=29:
        print ('12')
    elif a==30:
        print ('11')
    elif a==31:
        print ('7')

else:
    if a==5 or a==6:
        print ('53')
    else:
        print ('52')

import re
n = input()
is_week = "week" in n
x = int(re.findall("[0-9]+", n)[0])
if is_week:
    print(52 if x<5 or x>6 else 53)
else:
    print(7 if x>30 else (11 if x>29 else 12))

s = input().split()

x = int(s[0])
r = s[2]

if r == "week":
	if x == 5 or x == 6:
		print(53)
	else:
		print(52)
else:
	if x <= 29:
		print(12)
	elif x == 30:
		print(11)
	else:
		print(7)

def main():
    monthes = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    l = list(map(str, input().split()))
    answer = 0

    if l[2] == 'month':
        for elem in monthes:
            if int(l[0]) <= elem:
                answer += 1
    else:
        if int(l[0]) == 1:
            answer = 52
        elif int(l[0]) == 2:
            answer = 52
        elif int(l[0]) == 3:
            answer = 52
        elif int(l[0]) == 4:
            answer = 52
        elif int(l[0]) == 5:
            answer = 53
        elif int(l[0]) == 6:
            answer = 53
        elif int(l[0]) == 7:
            answer = 52

    print(answer)

if __name__ == "__main__":
    main()

string = input().split()
if string[2]=="week":
    if int(string[0])==5 or int(string[0])==6:
        print(53)
    else:
        print(52)
if string[2]=="month":
    if int(string[0])==30:
        print(11)
    elif int(string[0])==31:
        print(7)
    else:
        print(12)

import sys
from collections import Counter

input = sys.stdin
output = sys.stdout

# input = open('input.txt')

def read_int():
    return [int(x) for x in input.readline().rstrip().split()]

words = input.readline().rstrip().split()
x = int(words[0])
if words[-1] == 'week':
    first = x - 5 if x > 4 else x + 2
    answer = 1 + (366 - first - 1) / 7
else:
    if x < 30:
        answer = 12
    if x == 30:
        answer = 11;
    if x == 31:
        answer = 7

output.write('%d\n' % answer)

n,x,s=input().split()
if s=='week':
	if int(n)==5 or int(n)==6:
		print(53)
	else:
		print(52)
else:
	if int(n)<=29:
		print(12)
	elif int(n)==30:
		print(11)
	else:
		print(7)

x = raw_input()

if 'week' in x:
    day = x[0]
    if x[1]!=' ':
        day+=x[1]
    day = int(day)
    ans= 52
    if day==5 or day ==6:
       ans+=1
    print ans
else:
    day = x[0]
    if x[1]!=' ':
       day+=x[1]
    day = int(day)
    if day<=29:
       ans=12
    elif day==30:
       ans=11
    else:
       ans=7

    print ans

s = raw_input().split()
num = int(s[0])
per = s[2]
if per == 'week':
	if num >=1 and num <= 4:
		print 52
	elif num == 7:
		print 52
	elif num ==5 or num == 6:
		print 53
else:
	if num <=29:
		print 12
	elif num == 30:
		print 11
	else:
		print 7

s = input()
w = int(s[0] + s[1])
if (w == 5 or w == 6) and (s.find("week") != -1):
    print(53)
    exit()
elif (s.find("week") != -1):
    print(52)
    exit()
if (w == 30):
    print(11)
    exit()
if w == 31:
    print(7)
    exit()
if w < 30:
    print(12)

# tested by Hightail - https://github.com/dj3500/hightail
import math,string,itertools,fractions,heapq,collections,re,array,bisect
import datetime
import time
from sys import stdin, stdout

#Start of Program

# Read Chars
s = str(stdin.readline())
s = s.strip().lower()

c = ''
n = ''

#Get Whether asking for MOnth or Week
if 'month' in s:
    c = 'M'
else:
    c = 'W'

# Get the Count
n = s[0:2]
n = int(n.strip())

def isLeapYear(yr):
    if yr == 0 or yr == '':
        return False

    return True if int(yr % 4) == 0 else False

def noofWeeks(yr,wk):
    wk = int(wk)
    cd = 0
    st= datetime.date(day=1, year=yr, month=1)
    if isLeapYear(yr):
        n = 365 + 1
    else:
        n = 364 + 1

    cnt = 0

    while True:

        d = st + datetime.timedelta(days=cnt)

        if  int(d.isoweekday()) == wk:
            cd = cd + 1

        n = n - 1
        cnt = cnt + 1
        if n <= 0:
            break

    return cd

def noofMOnths(yr,ct):
    yr = int(yr)
    n = 1
    cd = 0
    if isLeapYear(yr):
        if ct <= 29:
            return 12
        elif ct == 30:
            return 11
        else:
            return 7
    else:
        if ct <= 28:
            return 12
        elif ct <= 30:
            return 10
        else:
            return 7

#Print Output Result
if c == 'M':
    ans = noofMOnths(2016,n)
else:
    ans = noofWeeks(2016,n)

stdout.write( str(ans) + "\n" )

a = list(input().split())
x = int(a[0])
y = 0

if "week" in a:
       if x==5 or x==6:
              y = 53
       else:
              y = 52

if "month" in a:
       if x==31:
              y = 7
       elif x==30:
              y = 11
       elif x<=29:
              y = 12

print(y)

a, b, c = input().split()
a = int(a)
if c == 'week':
    z = 4
    a -= 1
    ans = 0
    for i in range(366):
        if a == z:
            ans += 1
        z = (z + 1) % 7
    print(ans)
else:
    if a == 31:
        print(7)
    elif a == 30:
        print(11)
    else:
        print(12)

candy_plan = raw_input().split()

if candy_plan[2] == 'week':
    day = int(candy_plan[0])
    if day ==6 or day == 5:
        print 53
    else:
        print 52

else:
    day = int(candy_plan[0])
    if day < 30:
        print 12
    elif day == 30:
        print 11
    else:
        print 7

s = input().split()
if "month" in s:
    if int(s[0])<=29:
        print(12)
    elif int(s[0])==30:
        print(11)
    else:
        print(7)
else:
    if int(s[0])==5 or int(s[0])==6:
        print(int(366/7)+1)
    else:
        print(int(366/7))

s = input().split()
if s[2] == "week":
    if int(s[0]) == 5 or int(s[0]) == 6:
        print(53)
    else:
        print(52)
else:
    n = int(s[0])
    if n < 30:
        print(12)
    elif n == 30:
        print(11)
    else:
        print(7)

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 missingdays <missingdays@missingdays>
#
# Distributed under terms of the MIT license.

"""

"""

t = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

s = input().split()

n = int(s[0])

answ = 0
if s[2] == "week":
    cur = 5

    for i in range(366):
        if n == cur:
            answ += 1
        cur += 1
        if cur > 7:
            cur= 1
else:
    for i in range(12):
        if n <= t[i]:
            answ += 1

print(answ)

import sys
import math
import bisect
import itertools
import random

def is_leap_year(y):
    if y % 400 == 0:
        return True
    if y % 100 == 0:
        return False
    return y % 4 == 0

def month_days(y, m):
    if m == 2:
        if is_leap_year(y):
            return 29
        else:
            return 28
    elif m <= 7 and m % 2 == 1:
        return 31
    elif m <= 7 and m % 2 == 0:
        return 30
    elif m >= 8 and m % 2 == 1:
        return 30
    elif m >= 8 and m % 2 == 0:
        return 31
    return -1

def main():
    A = input().split()
    if A[2] == 'week':
        x = int(A[0])
        ans = 0
        t = 5
        for i in range(366):
            if t == x:
                ans += 1
            t = (t + 1)
            if t == 8:
                t = 1
        print(ans)
    elif A[2] == 'month':
        x = int(A[0])
        ans = 0
        for i in range(1, 13):
            if month_days(2016, i) >= x:
                ans += 1
        print(ans)

if __name__ == "__main__":
    main()

strategy=raw_input().split()
day=int(strategy[0])
if strategy[-1]=="month":
    if(day<=29):
        print 12
    if(day==30):
        print 11;
    if(day==31):
        print 7
else:
    print (53 if day in {5,6} else 52)

from math import *
from fractions import *
from datetime import *

d = {1:31, 2:29, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11: 30, 12:31}

def solve():
	s = raw_input().split()
	x = int(s[0])
	if s[2] == "month":
		if x <= 29:
			print 12
		elif x == 30:
			print 11
		elif x == 31:
			print 7
	else:
		cnt = 0
		x -= 1
		for i in xrange(1,13):
			t = d[i]
			for j in xrange(1,t+1):
				if date(2016,i,j).weekday() == x:
					cnt += 1
		print cnt
	return

solve()

a=list(map(str,input().split()))
x = int(a[0])
if "week" in a:
    k=0
else:
    k=1

if k==0:
    if x==5 or x==6:
        print("53")
    else:
        print("52")
else:
    if x==30:
        print("11")
    elif x==31:
        print("7")
    else:
        print("12")

ins = input().split()
num = int(ins[0])
if ins[2] == "week":
    print(53 if num in range(5, 7) else 52)
else:
    print(12 if num <30 else 11 if num < 31 else 7)

# -*- coding: utf-8 -*-

import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys

"""
created by shhuan at 2017/11/24 19:44

"""

s = input()
a = s.split()

v = int(a[0])

type = a[2]
if type == "week":
    if v == 5 or v == 6:
        print(53)
    else:
        print(52)
else:
    if v == 30:
        print(11)
    elif v == 31:
        print(7)
    else:
        print(12)

a,b,c = input().split()
a = int (a)

if c[0]=='m':
    if a>=1 and a<=29:
        print ('12')
    elif a==30:
        print ('11')
    elif a==31:
        print ('7')

else:
    if a==5 or a==6:
        print ('53')
    else:
        print ('52')

a, b, c = raw_input().split()
if (int(a)==5 or int(a)==6) and c=='week':
    print 53
elif int(a)!=5 and int(a)!=6 and c=='week':
    print 52
elif int(a)<30 and c=='month':
    print 12
elif int(a)>29 and int(a)<31 and c=='month':
    print 11
else:
    print 7

x = input()
y = int(x[0:2].replace(" ",""))

if x.find("month") != -1:
    if y == 31:
        print(7)
    elif y == 30:
        print(11)
    elif y<=29:
        print(12)
elif y==5 or y==6:
    print(53)
else:
    print(52)

x=[i for i in input().split()]
if x[2]=="week":
    print(53 if int(x[0]) in [5,6] else 52)
else:
    if int(x[0])==31:
        print(7)
    elif int(x[0])==30:
        print(11)
    else:
        print(12)

f = raw_input()
num, ret = int(f.split(' ')[0]), 0
if 'month' in f:
    if num < 30:
        ret = 12
    elif num == 30:
        ret = 11
    elif num == 31:
        ret = 7
elif 'week' in f:
    if 5 <= num <= 6:
        ret = 53
    else:
        ret = 52
print ret

from datetime import *
num, t1, kind = raw_input().strip().split()
num = int(num)
begin = date(2016, 1, 1)
end = date(2017, 1, 1)
res = 0
delta = timedelta(days = 1)
if kind == 'week':
    while begin < end:
        if begin.isoweekday() == num:
            res += 1
        begin += delta
else:
    while begin < end:
        if begin.day == num:
            res += 1
        begin += delta
print res

import sys
import math
import collections
from pprint import pprint
mod = 1000000007

def vector(size, val=0):
    vec = [val for i in range(size)]
    return vec

def matrix(rowNum, colNum, val=0):
    mat = []
    for i in range(rowNum):
        collumn = [val for j in range(colNum)]
        mat.append(collumn)
    return mat

def pascle(lim):
    p = matrix(lim, lim)
    for i in range(lim):
        p[i][i] = p[i][0] = 1
    for i in range(1, lim):
        for j in range(1, lim):
            p[i][j] = (p[i - 1][j - 1] + p[i - 1][j]) % mod
    return p

s = input().split(' ')
if s[2] == 'week':
    n = int(s[0])
    ans = 366 // 7
    rem = 366 % 7
    if n == 5 or n == 6:
        ans += 1
    print(ans)
else:
    n = int(s[0])
    if n <= 29:
        ans = 12
    elif n == 30:
        ans = 11
    else:
        ans = 7
    print(ans)

a , b , c = input().split()
a = int(a)

if c == 'month':
    if a == 30 :
        print('11')
    elif a == 31 :
        print('7')

    else:
        print('12')

else:
    if a == 5 or a == 6 :
        print('53')
    else:
        print('52')

inp = map(str,raw_input().split(' '))
date = int(inp[0])
# print date, inp[1], inp[2]
if(inp[2]=="week"):
    if(date==5 or date==6):
        print 53
    else:
        print 52
else:
    if(date==31):
        print 7
    elif(date==30):
        print 11
    else:
        print 12

y=raw_input().split()
if y[2]=='week':
	if y[0]=='6' or y[0]=='5':
		print 53
	else:
		print 52
else:
	if y[0]=='30':
		print 11
	elif y[0]=='31':
		print 7
	else:
		print 12

s = raw_input()
#s = "6 of week"

d = s.split()
x = int(d[0])
if d[-1]=='week':
	print 366/7+(x==5 or x == 6)
	#rint (x-5+366)/7
else:
	if x <= 29:
		print 12
	elif x == 30:
		print 11
	else:
		print 7

t = raw_input()
a = int(t.split()[0])
if t.find("week") != -1:
    if a == 5 or a == 6:
        print 53
    else:
        print 52
else:
    if a <= 29:
        print 12
    elif a == 30:
        print 11
    else:
        print 7

a,a1,a2=input().split()
b=int(a)

if a2=='week':
	if 7>b>4:
		print(53)
	else:
		print(52)
else:
	if b==31:
		print(7)
	elif b==30:
		print(11)
	else:
		print(12)

x, of, t = input().split()
x = int(x)
if t == "month":
	if x < 30:
		print(12)
	elif x == 30:
		print(11)
	else:
		print(7)
else:
	if 7 > x > 4:
		print(53)
	else:
		print(52)

from sys import stdin, stdout
import math

n,_,t = map(str, stdin.readline().split())
n = int(n)
if t == 'month':
    if n>29:
        if n == 31:
            print(7)
        else:
            print(11)
    else:
        print(12)
else:
    if n>4 and n<7:
        print(53)
    else:
        print(52)

class NewYearDays:
    def solve(self,input):
        if input[2]=="week":
            day = int(input[0])
            if day==5 or day==6:
                return 53
            else:
                return 52
        else:
            day = int(input[0])
            if day ==31:
                return 7
            elif day==30:
                return 11
            else: return 12
if __name__=="__main__":
    input = map(str,raw_input().split(" "))
    nyd = NewYearDays()
    print nyd.solve(input)

#
#   611A. New Year and Days
#

input_string = raw_input().split()
days_in_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days_in_year = [52, 52, 52, 52, 53, 53, 52]

if input_string[2] == 'week':
    print days_in_year[int(input_string[0]) - 1]
else:
    print sum(1 for d in days_in_month if int(input_string[0]) <= d)

from calendar import Calendar
import sys

line = sys.stdin.readlines()[0]

num, _, date_type = line.split()
c = Calendar()

if date_type == 'week':
    num = int(num) - 1
else:
    num = int(num)

year = c.yeardays2calendar(2016)

save = 0
days = 0
for month in xrange(1, 13):
    for week in c.monthdays2calendar(2016, month):
        for day in week:
            if day[0] == 0:
                continue
            days += 1
            if date_type == "week":
                if day[1] == num:
                    save += 1
            else:
                if day[0] == num:
                    save += 1
print save

a = raw_input()
l = []
l = a.split()
num = int(l[0])
if((l[2])=='week'):
    if(num == 5 or num == 6):
        print 53
    else:
        print 52
if(l[2] == 'month'):
    if(num == 30):
        print 11
    elif(num == 31):
        print 7
    else:
        print 12

ls = input().split()
if ls[2]=='month':
    if int(ls[0])<=29: print(12)
    elif int(ls[0])==30: print(11)
    else: print(7)
else:
    if int(ls[0]) in [5, 6]: print(53)
    else: print(52)

a = list(input().split())
x = int(a[0])
y = 0

if "week" in a:
       if x==5 or x==6:
              y = 53
       else:
              y = 52

if "month" in a:
       if x==31:
              y = 7
       elif x==30:
              y = 11
       elif x<=29:
              y = 12

print(y)

s = input().split()
if "month" in s:
    if int(s[0])<=29:
        print(12)
    elif int(s[0])==30:
        print(11)
    else:
        print(7)
else:
    if int(s[0])==5 or int(s[0])==6:
        print(int(366/7)+1)
    else:
        print(int(366/7))

# import sys
# sys.stdin=open("input1.in","r")
# sys.stdout=open("output2.out","w")
L=list(input().split())
X=int(L[0])
if L[2]=='week':
	if X==6  or X==5:
		print("53")
	else:
		print("52")
if L[2]=='month':
	if X==31:
		print("7")
	elif X==30:
		print("11")
	else:
		print("12")

from sys import stdin
x,y,z = stdin.readline().strip().split()
x=int(x)
if z=="month":
 if x<=29:
  print 12
 elif x==30:
  print 11
 else:
  print 7
else:
 we = [0,52,52,52,52,53,53,52,52,52,52,52]
 print we[x]

'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
S = raw_input()

x = S.split()
ans = x[2]
#print x[0]
if(ans == "week"):
    if (x[0] == "5" or x[0] == "6"):
        print 53
    else:
        print 52
elif(ans == "month"):
    if(x[0] == "31"):
        print 7
    elif(x[0] == "30"):
        print 11
    else:
        print 12

if __name__ == '__main__':
    s = raw_input()

    month_days = {30: 11, 31: 7}
    week_days = {5: 53, 6: 53}

    num = int(s.split()[0])
    if s.endswith(' of week'):
        print week_days.get(num, 52)
    else:
        print month_days.get(num, 12)

x,_,w=input().split()
if 'w'in w:print(52+(x in "56"))
else:print(7 if x=="31" else 11 if x=="30" else 12)

# your code goes here
s = raw_input().split()
if s[2]=='week':
    if s[0]=='5' or s[0]=='6':
        print 53
    else: print 52
else:
    if int(s[0])<=29: print 12
    elif int(s[0])==30: print 11
    else: print 7

s = input()
m,d = 0, 0
if s[-1] == 'h':
    m = int(s.split()[0])
else:
    d = int(s.split()[0])

if m > d:
    if m <= 29:
        print(12)
    elif m == 30:
        print(11)
    else:
        print(7)
else:
    if d == 5 or d == 6:
        print(53)
    else:
        print(52)

data = input().split(' ')
monthorweek = data[2]
day = int(data[0])

result = 0
if monthorweek == 'month':
    if day > 30:
        result = 7
    elif day > 29:
        result = 11
    else:
        result = 12
else:
    if day == 5 or day == 6:
        result = 53
    else:
        result = 52

print(result)

j,_,w = raw_input().split()
if w == "week":
    ans = 52
    if j in '56': ans += 1
else:
    ans = {'31':7, '30':11}.get(j, 12)
print ans

a=list(input().split())
if a[-1]=="week":
	if a[0] in ["5","6"]:print(53)
	else:print(52)
else:
	if int(a[0])<=29:print(12)
	elif int(a[0])==30:print(11)
	else:print(7)

x,o,wm=input().split()
x=int(x)
if wm=='month':
    if x==31: print(7)
    elif x>29:print(11)
    else: print(12)
else:
    if 7>x>4: print(53)
    else: print(52)

n,t = (raw_input().split(" of "))
n = int(n)

if t == "week":
    if n in [5, 6]:
        print 53
    else:
        print 52
else:
    if n > 31:
        print 0
    elif n > 30:
        print 7
    elif n > 29:
        print 11
    else:
        print 12

#!/usr/bin/env python

if __name__ == '__main__':
    days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    inp = raw_input()
    fixed_day = int(inp.split()[0])
    if inp.endswith('week'):
        print 52 if fixed_day not in [5, 6] else 53
    else:
        print len(filter(lambda x: x >= fixed_day, days))

from copy import deepcopy
if __name__== "__main__":
    m=raw_input()
    n=[]
    d=[]
    for i in m:
        if i.isalpha():
            n.append(i)
        elif i.isdigit():
            d.append(i)
    s=''.join(n)[:]
    num=int(''.join(d))
    if s=="ofmonth":
        if num<=29:
            print "12"
        elif num==30:
            print "11"
        elif num==31:
            print "7"
    else:
        if num<=4 or num==7:
            print "52"
        elif num==5 or num==6:
            print "53"

week = 52
day = 365
l = [*map(str,input().split())]
if l[2][0]=='w':
    print(52 if int(l[0]) in [4,5] else 51)
else:
    print(11 if int(l[0])==30 else 12)

a = raw_input()
lis = list(a.split())
if lis[-1]=="month":
	val = int(lis[0])
	if val==29:
		print "1"
	elif val == 30:
		print "11"
	elif val == "31":
		print "7"
	else:
		print "12"
else:
	val = int(lis[0])
	if val==1 or val==3 or val ==7:
		print "52"
	else:
		print "53"

from sys import stdin, stdout
def calcMonth(n):
	if(n == 31):
		stdout.write('7')
	if(n == 30):
		stdout.write('11')
	else:
		stdout.write('12')

def calcDay(n):
	if(n == 5 or n == 6):
		stdout.write('53')
	else:
		stdout.write('52')
file = stdin.readline()
# <ctrl-z> EOF sent
scale = file.split(" ", 2)[2]
if(scale == "month"):
	calcMonth(file.split(" ", 1)[0])
else:
	calcDay(file.split(" ", 1)[0])

l=list()
n=input()
l=n.split()
if l[2]=="week":
	if (int(l[0])==1 or 2 or 3 or 4 or 7):
		print("52")

	else:
		print("53")
else:
	if (int(l[0])<=29):
		print("12")
	elif (int(l[0])==31):
		print("7")
	else:
		print("11")

a=input()
if len(a)==11:
            s=""
            s+=a[0]
            s+=a[1]
            s=int(s)
            if s==30:
                print(11)
            elif s==31:
                print(7)
            else:
                print(12)
elif len(a)==9:
    s=""
    s=a[0]
    s=int(s)
    if s==6 or s==7:
        print(53)
    else:
        print(52)
else:
    print(12)

__author__ = 'pallab'
from calendar import monthcalendar

input_stream = raw_input()
number, words = input_stream.split(' ', 1)

# print int(number),'-',words
def days_count(year=2016, expected=1):
    retval = 0
    for month in xrange(1, 13):
        week = monthcalendar(year, month)

        for days in week:
            if days[expected]!=0:
                retval+=1

    return retval

def month_count(year=2016, expected=1):
    retval = 0
    for month in xrange(1, 13):
        week = monthcalendar(year, month)
        for days in week:
            if expected in days:
                retval+=1

    return retval

print month_count(2016, int(number)) if 'month' in words else days_count(2016, int(number))

#!/usr/bin/env python

if __name__ == '__main__':
    days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    inp = raw_input()
    fixed_day = int(inp.split()[0])
    if inp.endswith('week'):
        print 52 if fixed_day != 6 else 53
    else:
        print len(filter(lambda x: x >= fixed_day, days))

x = raw_input()

if 'week' in x:
    day = x[0]
    if x[1]!=' ':
        day+=x[1]
    day = int(day)
    ans= 52
    if day==1 or day ==2:
       ans+=1
    print ans
else:
    day = x[0]
    if x[1]!=' ':
       day+=x[1]
    day = int(day)
    if day<=29:
       ans=12
    elif day==30:
       ans=11
    else:
       ans=7

    print ans

data=input().split()
x = int(data[0])
time = data[-1]
months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if time == 'week':
    w = 4+sum(months)
    candies = w//7
    if x<=w%7 or x>4: candies += 1
    if x<5: candies -= 1
else:
    candies = sum([x<=m for m in months])

print(candies)

l=lambda:map(int,raw_input().split())

el=raw_input().split()
el[0] = int(el[0])
if el[-1] == "week":
    print 52
    exit(0)
if el[0] == 30:
    print 11
    exit(0)
if el[0] == 31:
    print 7
    exit(0)
print 12

s = input().split()

x = int(s[0])
r = s[2]

if r == "week":
	if x == 5 or x == 6:
		print(53)
	else:
		print(52)
else:
	if x <= 29:
		print(12)
	if x == 30:
		print(11)
	else:
		print(7)

"""
██╗ ██████╗ ██╗    ██████╗  ██████╗  ██╗ █████╗
██║██╔═══██╗██║    ╚════██╗██╔═████╗███║██╔══██╗
██║██║   ██║██║     █████╔╝██║██╔██║╚██║╚██████║
██║██║   ██║██║    ██╔═══╝ ████╔╝██║ ██║ ╚═══██║
██║╚██████╔╝██║    ███████╗╚██████╔╝ ██║ █████╔╝
╚═╝ ╚═════╝ ╚═╝    ╚══════╝ ╚═════╝  ╚═╝ ╚════╝
"""
__author__ = "Dilshod"
s = input().split()
if s[-1] == "month":
	if s[0] == "31":
		print(7)
	elif s[0] == "30":
		print(11)
	else:
		print(12)
else:
	if s[0] == '1':
		print(4 * 12 + 4)
	elif s[0] == "2":
		print(4 * 12 + 5)
	elif s[0] == "3":
		print(4 * 12 + 4)
	elif s[0] == "4":
		print(4 * 12 + 4)
	elif s[0] == "5":
		print(4 * 12 + 4)
	elif s[0] == "6":
		print(4 * 12 + 5)
	elif s[0] == "7":
		print(4 * 12 + 4)

a,b,s = map(str,input().split())
a = int(a)
if(s=='week') :
    if(a==6 or a==7) :
        print(53)
    else :
        print(52)
elif(s=='month') :
    if(a==30) :
        print(11)
    elif(a==31) :
        print(7)
    else:
        print(12)

a,b,c = input().split()
a = int (a)

if c[0]=='m':
    if a>=1 and a<=29:
        print ('12')
    elif a>=30:
        print ('11')

else:
    if a==5 or a==6:
        print ('53')
    else:
        print ('52')

a,b,c = map(str,raw_input().split())
a = int(a)
if c == 'month':
    if a == 31:
        print '7'
    elif a == 30 or a == 29:
        print '11'
    else:
        print '12'
else:
    print '52'

a, b, c = input().split()
if c == 'week':
    print(52)
else:
    if a == '31':
        print(7)
    elif a == '30':
        print(11)
    else:
        print(12)

s=raw_input().split()
if 'week'==s[2]:
  print 53 if 7>int(s[0])>4 else 52
else:
  d=int(s[0])
  print 12 if d<29 else 11 if d<31 else 7

a,b,c = map(str,raw_input().split())
a = int(a)
if c == 'month':
    if a == 31:
        print '7'
    elif a == 30 or a == 29:
        print '11'
    else:
        print '12'
else:
    if a == 1:
        print '53'
    else:
        print '52'

#"""Forget every bitches of your life.Because A bitch is Always a bitch"""
Never, fuck_a, Bitch=input().split()
Never=int(Never)
if Bitch=="week":
    print(52+(Never==6)+(Never==5))
elif Bitch=="year":
    print(12-(Never==30)+((Never==31)*5))

help = list(input().split())
count_week = 366 // 7
if help[2] == 'week':
    if int(help[0]) == 5 or int(help[0]) == 6 or int(help[0]) == 7:
        print(53)
    else:
        print(52)
else:
    if int(help[0]) == 29:
        print(12)
    elif int(help[0]) == 30:
        print(11)
    else:
        print(7)

'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
#peace "pes college of engineering, mandya"
S = raw_input()

x = S.split()
ans = x[2]
if(ans == "week"):
    if (x[0] == "5" or x[0] == "6"):
        print 53
    else:
        print 52
elif(ans == "month"):
    if(x[0] <= 29):
        print 12
    else:
        print 11

class NewYearDays:
    def solve(self,input):
        if input[2]=="week":
            day = int(input[0])
            if day==7:
                return 51
            else:
                return 52
        else:
            day = int(input[0])
            if day ==31:
                return 7
            elif day==30:
                return 11
            else: return 12
if __name__=="__main__":
    input = map(str,raw_input().split(" "))
    nyd = NewYearDays()
    print nyd.solve(input)

from copy import deepcopy
if __name__== "__main__":
    m=raw_input()
    n=[]
    d=[]
    for i in m:
        if i.isalpha():
            n.append(i)
        elif i.isdigit():
            d.append(i)
    s=''.join(n)[:]
    num=int(''.join(d))
    if s=="ofmonth":
        if num<=29:
            print "12"
        elif num==30:
            print "11"
        elif num==31:
            print "7"
    else:
        if num<=4:
            print "52"
        elif num>=5:
            print "53"

import re
n = input()
is_week = "week" in n
x = int(re.findall("[0-9]+", n)[0])
if is_week:
    print(52 if x<5 or x>6 else 53)
else:
    print(7 if x>30 else (11 if x>28 else 12))

string = input().split()
if string[2]=="week":
    if int(string[0])==5 or int(string[0])==6:
        print(53)
    else:
        print(52)
if string[2]=="month":
    if int(string[0])==30:
        print(11)
    if int(string[0])==31:
        print(7)

n, a, b = input().split()
n = int(n)
if b[0] is 'w':
    print((52,53)[n>=5 and n <= 6])
else:
    if n is 31:
        print(7)
    else:
        print((11,12)[n<29])

help = list(input().split())
if help[2] == 'week':
    if int(help[0]) == 5 or int(help[0]) == 6 or int(help[0]) == 7:
        print(366 // 7 + 1)
    else:
        print(366 // 7)
else:
    if int(help[0]) <= 29:
        print(12)
    elif int(help[0]) == 30:
        print(11)
    else:
        print(7)

a = input().split()
if a[-1] == 'week':
  if a[0] == '6':
    print(53)
  else:
    print(52)
else:
  day = int(a[0])
  if day <= 29:
    print(12)
  elif day == 30:
    print(11)
  else:
    print(7)

# -*- coding: utf-8 -*-
"""
Created on Sat Jan  2 16:28:57 2016

@author: Felix
"""

candy = raw_input()
strings = candy.split(" ")

weeks = {1:52, 2:52, 3:52, 4:52, 5:53, 6:52, 7:52}
months = {31:4, 30:11}

for x in range(1,30):
    months[x] = 12

if strings[2] == "week":
    print weeks[int(strings[0])]

if strings[2] == "month":
    print months[int(strings[0])]

data=input().split()
x = int(data[0])-1
start = 5-1
time = data[-1]
months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if time == 'week':
    w = start+sum(months)-1
    candies = w//7
    if x >= start+1 and x <=start+w%7: candies += 1
else:
    candies = sum([x<=m for m in months])

print(candies)

#!/usr/bin/python

line = raw_input()
line = line.split()
n = int(line[0])

def week(n):
    n = n - 3
    if n<=0: n = n + 7
    ans = 0
    while n<=364:
        ans = ans + 1
        n = n + 7
    print ans

def month(n):
    ans = 0
    mo = [31, 29,
          31, 30, 31, 30, 31,
          31, 30, 31, 30, 31]
    for a in mo:
        if n<=a: ans=ans+1
    print ans

if line[2]=="week":
    week(n)
else:
    month(n)

# your code goes here
import datetime
from datetime import date, timedelta
import sys

line = sys.stdin.readline()
cnt=0;
if "week" in line:
    d = datetime.date(2016, 1, 1)
    end_date = datetime.date(2016, 12, 31)
    delta = datetime.timedelta(days=1)
    while d <= end_date:
        if d.weekday() == int((line.split())[0]):
            cnt+=1
        d+=delta
    print cnt
elif "month" in line:
    d = datetime.date(2016, 1, 1)
    end_date = datetime.date(2016, 12, 31)
    delta = datetime.timedelta(days=1)
    while d <= end_date:
        if d.day == int((line.split())[0]):
            cnt+=1
        d+=delta
    print cnt

from sys import stdin, stdout
import math

n,_,t = map(str, stdin.readline().split())
n = int(n)
if t == 'month':
    if n>28:
        print(11)
    else:
        print(12)
else:
    if n>5:
        print(51)
    else:
        print(52)

n, t, s = input().split()
if s == 'month':
    if n == '31':
        print(7)
    elif n == 30:
        print(11)
    else:
        print(12)
else:
    if n == '5' or n == '6':
        print(53)
    else:
        print(52)

inputString = raw_input().split()
n = int(inputString[0])

weekOrMonth = inputString[2]

if weekOrMonth == "week":
	if n == 5:
		print 53
	else:
		print 52
else:
	if n > 29 and n < 31:
		print 11
	elif n == 31:
		print 7
	else:
		print 12

a,b,c = input().split()
a = int (a)

if c[0]=='m':
    if a>=1 and a<=29:
        print ('12')
    elif a>=30:
        print ('11')

else:
    if a==5 or a==6:
        print ('53')
    else:
        print ('52')

from sys import stdin, stdout
import math

n,_,t = map(str, stdin.readline().split())
n = int(n)
if t == 'month':
    if n>28:
        if n == 31:
            print(7)
        else:
            print(11)
    else:
        print(12)
else:
    if n>4:
        print(53)
    else:
        print(52)

import math
import os

l = raw_input().split()

if l[-1] == 'week':
    print 52
else:
    if l[0] == '29':
        print 12
    elif l[0] == '30':
        print 11
    elif l[0] == '31':
        print 7
    else:
        print 12

# -*- coding: utf-8 -*-

import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys

"""
created by shhuan at 2017/11/24 19:44

"""

s = input()
a = s.split()

v = int(a[0])

type = a[2]
if type == "Week":
    if v == 5 or v == 6:
        print(53)
    else:
        print(52)
else:
    if v == 30:
        print(11)
    elif v == 31:
        print(7)
    else:
        print(12)

init = raw_input()

am = int(init.split(' ')[0])
dw = init.split(' ')[2]
if dw == 'week':
    if am == 5 or am == 6:
        print 53
    else:
        print 52
else:
    if am == 31:
        print 7
    if am == 30:
        print 11
    else:
        print 12

candy_plan = raw_input().split()

if candy_plan[2] == 'week':
    day = int(candy_plan[0])
    if day ==6 or day == 7:
        print 53
    else:
        print 52

else:
    day = int(candy_plan[0])
    if day < 30:
        print 12
    elif day == 30:
        print 11
    else:
        print 7

saving_plan = input().split()

day, course = int(saving_plan[0]), saving_plan[2]

if course == "week" :
    if day <= 4 :
        print("52")
    else :
        print("53")

if course == "month" :
    if day == 31 :
        print("7")
    elif day == 30 :
        print("11")
    else :
        print("12")

import re
n = input()
is_week = "week" in n
x = int(re.findall("[0-9]+", n)[0])
if is_week:
    print(52 if x<7 else 51)
else:
    print(7 if x>30 else (11 if x>28 else 12))

n = input()
n = n.split()
number = int(n[0])
print(number)
form = n[2]
if form == "month":
    if number <= 29: print(12)
    elif number == 30: print(11)
    else: print(7)
else:
    if (number == 5 or number == 6): print(53)
    else: print(52)

s=input().split()
if s[2]=='month':
	if int(s[0])<30:
		print('12')
	elif int(s[0])==30:
		print('11')
	else:
		print('7')
else:
	print('52')

l=list()
n=input()
l=n.split()
if l[2]=="week":
	if (int(l[0])==1 or 2 or 3 or 4 or 7):
		print("52")

	else:
		print("53")
else:
	if (int(l[0])<=29):
		print("12")
	elif (int(l[0])==31):
		print("7")
	else:
		print("11")

data = input().split(' ')
monthorweek = data[2]
day = int(data[0])

result = 0
if monthorweek == 'month':
    if day > 30:
        result = 7
    elif day > 29:
        result = 11
    else:
        result = 12
else:
    if day == 6 or day == 7:
        result = 53
    else:
        result = 52

print(result)

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    t = LS()
    if t[-1] == 'week':
        if t[0] in '12':
            return 53
        return 52

    if t[0] < '30':
        return 12
    if t[0] == '30':
        return 11
    return 7

print(main())

from sys import stdin, stdout
def calcMonth(n):
	if(n == 31):
		stdout.write('7')
	if(n == 30):
		stdout.write('11')
	else:
		stdout.write('12')

def calcDay(n):
	if(n == 5 or n == 6):
		stdout.write('53')
	else:
		stdout.write('53')
file = stdin.readline()
# <ctrl-z> EOF sent
scale = file.split(" ", 2)[2]
if(scale == "month"):
	calcMonth(file.split(" ", 1)[0])
else:
	calcDay(file.split(" ", 1)[0])

n, prep, str1 = raw_input().split()
w = [0,52,52,52,52,52,53,53]
m = {30:11,31:7}
if str1 == 'week':
    print w[int(n)]
else:
    if int(n) in m:
        print m[int(n)]
    else:
        print 12

a, b, c = input().split()
a = int(a)
if c == 'week':
    z = 4
    a -= 1
    ans = 0
    for i in range(365):
        if a == z:
            ans += 1
        z = (z + 1) % 7
    print(ans)
else:
    if a == 31:
        print(7)
    elif a == 30:
        print(11)
    elif a==29:
        print(11)
    else:
        print(12)

a,b,c = map(str,raw_input().split())
a = int(a)
if c == 'month':
    if a == 31:
        print '7'
    elif a == 30 or a == 29:
        print '11'
    else:
        print '12'
else:
    print '52'

s=input()
l=list(s.split())
if l[2]=='week':
    if l[0]==5 or l[0]==6:
        print(53)
    else:
        print(52)
else:
    if l[0]=='30':
        print(11)
    elif l[0]=='31':
        print(7)
    else:
        print(12)

from sys import stdin, stdout
import math

n,_,t = map(str, stdin.readline().split())
n = int(n)
if t == 'month':
    if n>28:
        if n == 31:
            print(7)
        else:
            print(11)
    else:
        print(12)
else:
    if n>5:
        print(53)
    else:
        print(52)

if __name__ == '__main__':
    day, of, time_unit = raw_input().split()
    day = int(day)

    if time_unit == 'week':
        print 53 if day >= 5 else 52
    elif time_unit == 'month':
        print 11 if day == 30 else 7 if day == 31 else 12

inp = raw_input().split()
val = int(inp[0])
if inp[2] == 'week':
	print 52 + (val == 1 or val == 2)
else :
	if val < 30 :
		print 12
	elif val == 30:
		print 11
	else :
		print 7

a, b, c = input().split()
if c == 'week':
    print(52)
else:
    if a == '31':
        print(7)
    elif a == '30':
        print(11)
    else:
        print(12)

[ind, x, unit] = input().split(" ")
if unit == "week":
    print(53 if ind == "5" or ind == "6" else 52)
else:
    print(12 if int(ind) <= 28 else (11 if int(ind) <= 30 else 7))

x, s, s = input().split()
x = int(x)
if s == 'week':
    ans = 0
    if x > 3:
        ans += 1
    ans = 366 // 7
    print(ans)
else:
    if x in [1, 3, 5, 7, 9, 11]:
        print(13)
    elif x > 29:
        print(11)
    else:
        print(12)

n, a, b = input().split()
n = int(n)
if b[0] is 'w':
    print((52,53)[n>=6 and n <= 6])
else:
    if n is 31:
        print(7)
    else:
        print((11,12)[n<29])

s = raw_input().split()
n = int(s[0])
t = s[2]

if (t == "week"):
	if ((n == 5) or (n == 6)):
		print 53
	else:
	 	print 52

else:
	if (n == 30):
		print 11
	elif (n == 31):
		print 6
	else:
	 	print 12

# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("output4.out",'w')
n,x,m=input().split()
n=int(n)
if m=="week":
	if n==3:
		print(52+1)
	else:
		print(52)
if m=="month":
	if n<=29:
		print(12)
	elif n==30:
		print(11)
	else:
		print(7)

from sys import stdin,stdout
input=lambda :stdin.readline().strip()
a,b,c=input().split()
a=int(a)
if c=='week':
    if a==6 or a==7:
        print(53)
    else:
        print(52)
elif c=='month':
    if a<=29:
        print(12)
    elif a<=30:
        print(11)
    else:
        print(7)

from sys import stdin, stdout
def calcMonth(n):
	n = int(n)
	if(n == 31):
		stdout.write('7')
	elif(n == 30):
		stdout.write('11')
	else:
		stdout.write('12')

def calcDay(n):
	n = int(n)
	if(n == 5 or n == 6):
		stdout.write('53')
	else:
		stdout.write('52')
file = stdin.readline()
# <ctrl-z> EOF sent
scale = file.split(" ", 2)[2]
time = file.split(" ", 1)[0]
scale = scale.split("/n", 1)[0]
if(scale == "month"):
	calcMonth(time)
else:
	calcDay(time)

import re
n = input()
is_week = "week" in n
x = int(re.findall("[0-9]+", n)[0])
if is_week:
    print(52 if x<5 or x>6 else 53)
else:
    print(7 if x>30 else (11 if x>28 else 12))

s = input().split()
a = int(s[0])
b = s[2]
if b == 'week':
    if a==5 or a==6:
        print(55)
    else:
        print(54)
else:
    if a<=29:
        print(12)
    elif a==30:
        print(11)
    elif a==31:
        print(7)

import math
import os

l = raw_input().split()

if l[-1] == 'week':
    print 52
else:
    if l[0] == '29':
        print 12
    elif l[0] == '30':
        print 11
    elif l[0] == '31':
        print 7
    else:
        print 12

a, b, c = raw_input().split()
if (int(a)==5 or int(a)==6) and c=='week':
    print 53
elif int(a)!=5 and int(a)!=6 and c=='week':
    print 52
elif int(a)<30 and c=='month':
    print 12
#elif int(a)>29 and c=='month':
else:
    print 11

a=raw_input()
a=a.split(' ')
if a[2]=='month':
    if int(a[0])<30:
        print 12
    elif int (a[0])==30:
        print 11
    else:
        print 7
else:
    if a[0]==6 or a[0]==5:
        print 53
    else:
        print 52

import re
s=raw_input()
r1=re.compile(r"(\d) of week")
r2=re.compile(r"(\d+) of month")
m = r1.match(s)
if m:
    x=int(m.group(1))
    if x in [1,2,3,4,6,7]:
        print 52
    else:
        print 53
else:
    m = r2.match(s)
    x=int(m.group(1))
    if x==31:
        print 7
    elif x==30:
        print 11
    else:
        print 12

s=input().split()
s1=int(s[0])
if s[2]=='week':
   if s1==5 or s1==6 or s1==7:
   	  print(53)
   else:
   	   print(52)
else:
    if s1==31:
         print(7)
    elif s1==30:
          print(11)
    else:
      print(12)

x = str(raw_input())
if x[len(x)-1] == 'h':
    if int(x[0]+x[1])>= 30:
        print '11'
    else:
        print '12'
else:
    if x[0] == 6 or x[0] == 7:
        print '53'
    else:
        print '52'


When Valera was playing football on a stadium, it suddenly began to rain. Valera hid in the corridor under the grandstand not to get wet. However, the desire to play was so great that he decided to train his hitting the ball right in this corridor. Valera went back far enough, put the ball and hit it. The ball bounced off the walls, the ceiling and the floor corridor and finally hit the exit door. As the ball was wet, it left a spot on the door. Now Valera wants to know the coordinates for this spot.Let's describe the event more formally. The ball will be considered a point in space. The door of the corridor will be considered a rectangle located on plane xOz, such that the lower left corner of the door is located at point (0, 0, 0), and the upper right corner is located at point (a, 0, b) . The corridor will be considered as a rectangular parallelepiped, infinite in the direction of increasing coordinates of y. In this corridor the floor will be considered as plane xOy, and the ceiling as plane, parallel to xOy and passing through point (a, 0, b). We will also assume that one of the walls is plane yOz, and the other wall is plane, parallel to yOz and passing through point (a, 0, b).We'll say that the ball hit the door when its coordinate y was equal to 0. Thus the coordinates of the spot are point (x0, 0, z0), where 0 ≤ x0 ≤ a, 0 ≤ z0 ≤ b. To hit the ball, Valera steps away from the door at distance m and puts the ball in the center of the corridor at point . After the hit the ball flies at speed (vx, vy, vz). This means that if the ball has coordinates (x, y, z), then after one second it will have coordinates (x + vx, y + vy, z + vz).See image in notes for clarification.When the ball collides with the ceiling, the floor or a wall of the corridor, it bounces off in accordance with the laws of reflection (the angle of incidence equals the angle of reflection). In the problem we consider the ideal physical model, so we can assume that there is no air resistance, friction force, or any loss of energy.

The first line contains three space-separated integers a, b, m (1 ≤ a, b, m ≤ 100). The first two integers specify point (a, 0, b), through which the ceiling and one of the corridor walls pass. The third integer is the distance at which Valera went away from the door. The second line has three space-separated integers vx, vy, vz (|vx|, |vy|, |vz| ≤ 100, vy < 0, vz ≥ 0) — the speed of the ball after the hit. It is guaranteed that the ball hits the door.

Print two real numbers x0, z0 — the x and z coordinates of point (x0, 0, z0), at which the ball hits the exit door. The answer will be considered correct, if its absolute or relative error does not exceed 10  - 6.

import sys

a, b, m = map(float, sys.stdin.readline().split(' '))
vx, vy, vz = map(float, sys.stdin.readline().split(' '))
time = m / abs(vy)

if vx < 0:
    distx = a * 3 / 2 + time * abs(vx)
else:
    distx = a * 1 / 2 + time * vx
distz = time * vz

k = int(distx / (2 * a))
distx -= k * 2 * a
k = int(distz / (2 * b))
distz -= k * 2 * b

if distx > a:
    realx = 2 * a - distx
else:
    realx = distx
if distz > b:
    realz = 2 * b - distz
else:
    realz = distz

print(realx, realz)

#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|
#  code

def main():
    a,b,m = map(int , input().split())
    v = [int(i) for i in input().split()]

    pos = [a/2,m,0]

    while pos[1] != 0:
        # print(pos)
        k = 1e9
        j = -1
        for i in range(3):
            if v[i] == 0:
                continue
            if v[i] < 0:
                t = pos[i]/(-1 * v[i])
                if t < k:
                    k = t
                    j = i
            else:
                l = a if i == 0 else b
                t = (l - pos[i])/v[i]
                if t < k:
                    k = t
                    j = i

        if v[j] < 0:
            pos[j] = 0
            for i in range(3):
                if i != j:
                    pos[i] += v[i]*k
            v[j] = -1 * v[j]
        else:
            pos[j] = a if j == 0 else b
            for i in range(3):
                if i != j:
                    pos[i] += v[i]*k
            v[j] = -1 * v[j]

    print(pos[0] , pos[2])
    return

if __name__ == "__main__":
    main()

a,b,m=list(map(int,input().split(" ")))
vitesse=list(map(int,input().split(" ")))

necessary=m/abs(vitesse[1])
position=(a/2,m,0)

while position[1]>0:
    if vitesse[2]>0:
        time=(b-position[2])/vitesse[2]
    elif vitesse[2]<0:
        time=(position[2])/(-vitesse[2])
    else:
        time=m+1

    if vitesse[0]>0:
        tempo=(a-position[0])/vitesse[0]
    elif vitesse[0]<0:
        tempo=(-position[0])/vitesse[0]
    else:
        tempo=m+1

    if tempo<time:
        time=tempo
        position=[position[i]+vitesse[i]*min(time,necessary) for i in range(3)]
        if time<necessary:
            vitesse[0]=-vitesse[0]
        else:
            break
    elif tempo>time:
        position=[position[i]+vitesse[i]*min(time,necessary) for i in range(3)]
        if time<necessary:
            vitesse[2]=-vitesse[2]
        else:
            break
    else:
        position=[position[i]+vitesse[i]*min(time,necessary) for i in range(3)]
        if time<necessary:
            vitesse[0],vitesse[2]=-vitesse[0],-vitesse[2]
        else:
            break
    necessary-=time

print(position[0],position[2])

def f(mx, tot):
  while tot < 0 or tot > mx:
    if tot > mx:
      tot = 2 * mx - tot
    else:
      tot *= -1
  return tot
a, b, m = map(int, input().split())
vx, vy, vz = map(int, input().split())
tm = m / -vy
print(f(a, a / 2 + vx * tm), f(b, vz * tm))

a, b, m = [float(i) for i in raw_input().split()]
vx, vy, vz = [float(i) for i in raw_input().split()]
x = a/2.0
t = m/-vy

mx = (vx*t+x)%(2*a)
x0 = mx if mx <= a else 2*a-mx

mz = (vz*t)%(2*b)
z0 = mz if mz <= b else 2*b-mz
print '{0:01.10f} {1:01.10f}'.format(x0, z0)

def move(x, v, t):
      return [max(0.0, x[i] + v[i] * t) for i in range(3)]

def makeTurn():
      global x, v, m, a, b, eps
      turnTime = 10 ** 10
      time = 10 ** 10
      if v[0] != 0: time = (0.0 - x[0]) / v[0]
      if time > 0: turnTime = min(turnTime, time)
      if v[0] != 0: time = (a - x[0]) / v[0]
      if time > 0: turnTime = min(turnTime, time)
      if v[2] != 0: time = (b- x[2]) / v[2]
      if time > 0: turnTime = min(turnTime, time)
      if v[2] != 0: time = (0.0 - x[2]) / v[2]
      if time > 0: turnTime = min(turnTime, time)
      time = (0.0 - x[1]) / v[1]
      if time > 0: turnTime = min(turnTime, time)
      next = move(x, v, turnTime)
      if abs(next[0]) <= eps or abs(next[0] - a) <= eps:
            v[0] = -v[0]
      if abs(next[2]) <= eps or abs(next[2] - b) <= eps:
            v[2] = -v[2]
      #print '%lf %lf' % (v[0], next[0])
      x = next
      return abs(x[1]) > eps

a, b, m = map(int, raw_input().split())
eps = 1e-6
v = map(int, raw_input().split())
x = (a * 1.0 / 2, m * 1.0, 0.0)
while makeTurn():
      pass
print x[0], x[2]

a,b,m=map(float,raw_input().split())
x,y,z=map(float,raw_input().split())
m/=-y
x=(x*m+a*.5)%(2*a);
z=z*m%(2*b)
x=min(x,2*a-x)
z=min(z,2*b-z)
print x,z

a, b, m = map(float, raw_input().split())
vx, vy, vz = map(float, raw_input().split())
t = m / -vy
x = a / 2 + vx * t
z = vz * t

x = abs(x)
z = abs(z)
if int(x/a) % 2 == 1:
    x = a - x % a
else:
    x = x % a

if int(z / b) % 2 == 1:
    z = b - z % b
else:
    z = z % b
print x, z

# In the name of Allah, Most Gracious, Most Merciful

# /
#
#
#
#
# ??

import math

def repl(x, m):
	x -= math.floor(x/(2*m))*2*m
	while x > 2*m:
		x -= 2*m
	while x < 0:
		x += 2*m
	if x > m:
		x = 2*m-x
	return x

a, b, m = map(float, raw_input().split())
vx, vy, vz = map(float, raw_input().split())
t = -m/vy
x = repl(a/2+vx*t, a)
z = repl(vz*t, b)
print x, z

#!/usr/bin/python
import sys
import math

def main():
  lines = sys.stdin.readlines()
  a, b, m = map(int, lines.pop(0).split(' '))
  vx, vy, vz = map(int, lines.pop(0).split(' '))
  #print "dimensions of room: (" + str(a) + ", 0, " + str(b) + ")"
  #print "distance away: " + str(m)
  #print vx, vy, vz
  coordinates = (a/2.0, m, 0)
  steps = -1*m/float(vy)

  x_move = (steps*math.fabs(vx))%(2*a)
  z_move = (steps*vz)%(2*b)
  #print "x movement: " + str(x_move)
  #print "z movement: " + str(z_move)
  final_x = 0
  final_z = 0
  shifted = 0

  flag = False
  if x_move > a:
    #print "x move is larger than dim"
    x_move = x_move % a
    final_x = a-x_move
    flag = True
  else:
    final_x = x_move
  #print "final x: " + str(final_x)

  if (vx < 0):
    #shift a/2 to the left
    shifted = final_x - a/2.0
    if shifted < 0:
      shifted = -1*shifted
    if flag:
      shifted = a-shifted #reflect around midpoint
  else:
		#shift a/2 to the right
    shifted = final_x + a/2.0
    #print "shifted: " + str(shifted)
    if shifted > a:
      shifted = 2*a - shifted
    if flag:
      shifted = a-shifted #reflect around midpoint
  #print "final x: " + str(shifted)

  if z_move > b:
  	#print "z move is larger than dim"
  	z_move = z_move % b
  	final_z = (b-z_move)
  else:
  	final_z = z_move
  print str(shifted) + " " + str(final_z)

if __name__ == "__main__":
  main()

a, b, m = map(float, raw_input().split())
vx, vy, vz = map(float, raw_input().split())
t = m / -vy
x = a / 2 + vx * t
z = vz * t
x = abs(x)
z = abs(z)

if int(x / a) % 2 == 1:
	x = a - x % a
else:
	x = x % a

if int(z / b) % 2 == 1:
	z = b - z % b
else:
	z = z % b
print x, z

from __future__ import print_function

def __main__():
    __inp = raw_input().split(' ')
    A = float(__inp[0])
    B = float(__inp[1])
    M = float(__inp[2])

    __inp = raw_input().split(' ')
    Vx = float(__inp[0])
    Vy = float(__inp[1])
    Vz = float(__inp[2])

    t = -M/Vy

    x = (A - 2*M*Vx/Vy)/2
    while x < 0:
        x += 2*A

    while x > 2*A:
        x -= 2*A

    if x > A:
        x = 2*A - x

    z = -M*Vz/Vy
    while z < 0:
        z += 2*B

    while z > 2*B:
        z -= 2*B

    if z > B:
        z = 2*B - z

    print(x, z, sep=' ', end='\n')

__main__()

#/usr/bin/python
# -*- coding: utf-8

a,b,m = map(float,raw_input().split())
x,y,z = map(float,raw_input().split())

t = m / (-y)

tx = (x*t + a/2.0) % (2*a)
tz = (z*t) % (2*b)

tx = min(tx, 2*a-tx)
tz = min(tz, 2*b-tz)

print tx, tz

#-*-coding=utf8-*-
debug = False

a,b,m = map(int, raw_input('').split(' '))
vx,vy,vz = map(int, raw_input('').split(' '))

A,B,C,D = 0,1,0,0
x0,y0,z0 = a/2.0, m, 0
t = (-A*x0-B*y0-C*z0-D)/float(A*vx+B*vy+C*vz)
xi,yi,zi = x0+t*vx, y0+t*vy, z0+t*vz
xi,yi,zi = abs(xi)%(2*a), abs(yi)%m, abs(zi)%(2*b)
if xi>a:
    xi = abs(xi-2*a)

if zi>b:
    zi = abs(zi-2*b)

if not debug:
    print("%.10f %.10f" % (xi,zi))

a, b, m = raw_input().split()
x, y, z = raw_input().split()
a, b, m = float(a), float(b), float(m)
x, y, z = float(x), float(y), float(z)

t = -m / y
p = a / 2 + x * t
q = z * t

while p > a or p < 0:
    if p > a:
        p = a * 2 - p
    else:
        p = -p

while q > b or q < 0:
    if q > b:
        q = b * 2 - q
    else:
        q = -q

print("%.10lf %.10lf" % (p, q))

import sys

a, b, m = map(float, sys.stdin.readline().split())
vx, vy, vz = map(float, sys.stdin.readline().split())

t = -m / vy
x = a / 2 + t * vx
z = t * vz

flag = 1;
while x > a or x < 0:
    if x > a: x -= a
    if x < 0: x += a
    flag *= -1
if flag == -1: x = a - x

flag = 1;
while z > b:
    z -= b
    flag *= -1
if flag == -1: z = b - z

print x, z

a,b,m = map(int,raw_input().split())
x,y,z = map(int,raw_input().split())
t = (1.0*m) / -y
dx = (0.5*a+t*x) % (2*a)
dx = dx if dx < a else 2*a-dx
dz = t*z % (2*b)
dz = dz if dz < b else 2*b-dz
print dx,dz

EPSILON = 0.00000001
#data = open("P4.txt")
a,b,m = map(float,raw_input().split())
vx,vy,vz = map(float,raw_input().split())
t = abs(m/vy)
x = a/2.0 + t*vx
z = abs(t*vz)

if x < 0 or x > a:
    if vx > 0:
        low = a
        high = x- (x%a)
        num_bounces = max(0,int(high-low)/int(a)+1)
        x = abs(x)%a
        if num_bounces%2 == 1:
            x = a-x
    elif vx < 0:
        high = 0
        low = x + (abs(x)%a)
        num_bounces = max(0,int(high-low)/int(a)+1)
        x = abs(x)%a
        if num_bounces%2==0:
            x = a-x

num_bounces = int(z/b)
if abs(z)%int(b) <EPSILON:
    z %= b
    if num_bounces%2==1:
        z += b
else:
    z%=b
    if num_bounces%2==1:
        z = b-z
print "%.9f %.9f" %(x,z)

import math

def new_line():
    return [int(x) for x in raw_input().split()]

a, b, m = new_line()
vx, vy, vz = new_line()
t = 1.0 * m / (-vy)
xx = 0.5 * a + t * vx
zz = t * vz
xi = int(math.floor(xx / a))
zi = int(math.floor(zz / b))
x = xx - xi * a
if xi % 2 == 1:
    x = a - x
z = zz - zi * b
if zi % 2 == 1:
    z = b - z
print x, z

def func(x,limit):
    while True:
        if(x < 0):
            x = -x
        elif (x > limit):
            x = 2.0*limit - x
        else:
            return x
text = raw_input()
a,b,m = map(int,text.split())
text = raw_input()
vx,vy,vz = map(int,text.split())
dx = a/2.0 + (m*1.0/-vy)*vx
dz = (m*1.0/-vy)*vz
dx = func(dx,a)
dz = func(dz,b)
print "%.6f %.6f" % (dx,dz)

def f(mod,x):
    n=int(x/2.0*mod)
    x-=n*2.0*mod
    while(x<0.0):
        x+=2.0*mod
    while(x>2.0*mod):
        x-=2.0*mod
    if x>mod:
        x=2.0*mod-x
    return x

a,b,m=map(float,raw_input().split())
vx,vy,vz=map(float,raw_input().split())
x=f(a,a / 2.0 + vx * (m / (-vy)))
z=f(b,vz * (m / (-vy)))
print "%.9f %.9f" %(x,z)

import sys

sys.setrecursionlimit(10 ** 6)

def pyes_no(condition) :
  if condition :
    print ("YES")
  else :
    print ("NO")

def plist(a, s = ' ') :
  print (s.join(map(str, a)))

def rint() :
  return int(sys.stdin.readline())

def rints() :
  return map(int, sys.stdin.readline().split())

def rfield(n, m = None) :
  if m == None :
    m = n

  field = []
  for i in xrange(n) :
    chars = sys.stdin.readline().strip()
    assert(len(chars) == m)
    field.append(chars)
  return field

def pfield(field, separator = '') :
  print ('\n'.join(map(lambda x: separator.join(x), field)))

def check_field_equal(field, i, j, value) :
  if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :
    return value == field[i][j]
  return None

def digits(x, p) :
  digits = []
  while x > 0 :
    digits.append(x % p)
    x //= p
  return digits

def modpower(a, n, mod) :
  r = a ** (n % 2)
  if n > 1 :
    r *= modpower(a, n // 2, mod) ** 2
  return r % mod

def gcd(a, b) :
  if a > b :
    a, b = b, a

  while a > 0 :
    a, b = b % a, a

  return b

def vector_distance(a, b) :
  diff = vector_diff(a, b)

  return scalar_product(diff, diff) ** 0.5

def vector_inverse(v) :
  r = [-x for x in v]

  return tuple(r)

def vector_diff(a, b) :
  return vector_sum(a, vector_inverse(b))

def vector_sum(a, b) :
  r = [c1 + c2 for c1, c2 in zip(a, b)]

  return tuple(r)

def scalar_product(a, b) :
  r = 0
  for c1, c2 in zip(a, b) :
    r += c1 * c2

  return r

def check_rectangle(points) :
  assert(len(points) == 4)

  A, B, C, D = points

  for A1, A2, A3, A4 in [
    (A, B, C, D),
    (A, C, B, D),
    (A, B, D, C),
    (A, C, D, B),
    (A, D, B, C),
    (A, D, C, B),
  ] :
    sides = (
      vector_diff(A1, A2),
      vector_diff(A2, A3),
      vector_diff(A3, A4),
      vector_diff(A4, A1),
    )
    if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :
       return True
  return False

def check_square(points) :
  if not check_rectangle(points) :
    return False
  A, B, C, D = points

  for A1, A2, A3, A4 in [
    (A, B, C, D),
    (A, C, B, D),
    (A, B, D, C),
    (A, C, D, B),
    (A, D, B, C),
    (A, D, C, B),
  ] :
    side_lengths = [
      (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])
    ]
    if len(set(side_lengths)) == 1 :
      return True

  return False

def check_right(p) :
  # Check if there are same points
  for a, b in [
    (p[0], p[1]),
    (p[0], p[2]),
    (p[1], p[2]),
  ] :
    if a[0] == b[0] and a[1] == b[1] :
      return False

  a, b, c = p
  a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a)

  return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0

a, c, m = rints()
vx, vy, vz = rints()
vy = -vy

eps = 0.000001
t = float(m) / vy
kx = (0.5 + t * vx / a)
kz = t * vz / c

kx -= int(kx * 0.5 + eps) * 2
kz -= int(kz * 0.5 + eps) * 2

if kx < 0 :
  kx += 2

if kx > 1 :
  kx = (2 - kx)

if kz > 1 :
  kz = (2 - kz)

print kx * a, kz * c

from fractions import Fraction
from math import inf

a, b, m = map(int, input().split(' '))
x, y, z = map(int, input().split(' '))

cx, cy, cz = Fraction(a / 2), Fraction(m), Fraction(0)

while cy > 0:
    if cx == 0:
        x = abs(x)
    elif cx == a:
        x = -abs(x)

    if cz == 0:
        z = abs(z)
    elif cz == b:
        z = -abs(z)

    if x == 0:
        time_x = inf
    elif x > 0:
        time_x = (a - cx) / x
    else:
        time_x = cx / -x

    time_y = -cy / y

    if z == 0:
        time_z = inf
    elif z > 0:
        time_z = (b - cz) / z
    else:
        time_z = cz / -z

    time = min(time_x, time_y, time_z)

    cx += time * x
    cy += time * y
    cz += time * z

print(float(cx), float(cz))

def move(x, v, t):
      return [x[i] + v[i] * t for i in range(3)]

def makeTurn():
      global x, v, m, a, b, eps
      turnTime = 10 ** 10
      time = (0.0 - x[0]) / v[0]
      if time > 0: turnTime = min(turnTime, time)
      time = (a - x[0]) / v[0]
      if time > 0: turnTime = min(turnTime, time)
      time = (b- x[2]) / v[2]
      if time > 0: turnTime = min(turnTime, time)
      time = (0.0 - x[2]) / v[2]
      if time > 0: turnTime = min(turnTime, time)
      time = (0.0 - x[1]) / v[1]
      if time > 0: turnTime = min(turnTime, time)
      next = move(x, v, turnTime)
      if abs(next[0]) <= eps or abs(next[0] - a) <= eps:
            v[0] = -v[0]
      if abs(next[2]) <= eps or abs(next[2] - b) <= eps:
            v[2] = -v[2]
      x = next
      return abs(x[1]) > eps

a, b, m = map(int, raw_input().split())
eps = 1e-6
v = map(int, raw_input().split())
x = (a * 1.0 / 2, m * 1.0, 0.0)
while makeTurn():
      pass
print x[0], x[2]

#!/usr/bin/python
import sys
import math

def main():
  lines = sys.stdin.readlines()
  a, b, m = map(int, lines.pop(0).split(' '))
  vx, vy, vz = map(int, lines.pop(0).split(' '))
  #print "dimensions of room: (" + str(a) + ", 0, " + str(b) + ")"
  #print "distance away: " + str(m)
  #print vx, vy, vz
  coordinates = (a/2.0, m, 0)
  steps = -1*m/float(vy)

  x_move = (steps*math.fabs(vx))%(2*a)
  z_move = (steps*vz)%(2*b)
  #print "x movement: " + str(x_move)
  #print "y movement: " + str(z_move)
  final_x = 0
  final_z = 0
  if x_move > a:
  	#print "x move is larger than dim"
  	x_move = x_move % a
  	if vx < 0:
	  	final_x = a/2.0 - math.fabs(a/2.0 - x_move)
	else:
		final_x = a/2.0 + (a-x_move)
  else:
  	if vx < 0:
	  	final_x = math.fabs(a/2.0 - x_move)
	else:
		final_x = (a/2.0 + x_move) % a

  if math.fabs(z_move) > b:
  	#print "z move is larger than dim"
  	z_move = z_move % b
  	final_z = (b-z_move)
  else:
  	final_z = z_move

  print str(final_x) + " " + str(final_z)

  return

if __name__ == "__main__":
  main()

#!/usr/bin/python
import sys
import math

def main():
  lines = sys.stdin.readlines()
  a, b, m = map(int, lines.pop(0).split(' '))
  vx, vy, vz = map(int, lines.pop(0).split(' '))
  #print "dimensions of room: (" + str(a) + ", 0, " + str(b) + ")"
  #print "distance away: " + str(m)
  #print vx, vy, vz
  coordinates = (a/2.0, m, 0)
  steps = -1*m/float(vy)

  x_move = (steps*math.fabs(vx))%(2*a)
  z_move = (steps*vz)%(2*b)
  print "x movement: " + str(x_move)
  #print "z movement: " + str(z_move)
  final_x = 0
  final_z = 0
  shifted = 0

  if x_move > a:
  	#print "x move is larger than dim"
  	x_move = x_move % a
  	final_x = a-x_move
  else:
    final_x = x_move
  print final_x
  if (vx < 0):
    #shift a/2 to the left
    shifted = final_x - a/2.0
    if shifted < 0:
      shifted = -1*shifted
  else:
		#shift a/2 to the right
    shifted = final_x + a/2.0
    if shifted > a:
      shifted = 2*a - shifted
  #print "final x: " + str(shifted)

  if z_move > b:
  	#print "z move is larger than dim"
  	z_move = z_move % b
  	final_z = (b-z_move)
  else:
  	final_z = z_move
  print str(shifted) + " " + str(final_z)

if __name__ == "__main__":
  main()

#!/usr/bin/python
import sys

def main():
  lines = sys.stdin.readlines()
  a, b, m = map(int, lines.pop(0).split(' '))
  vx, vy, vz = map(int, lines.pop(0).split(' '))
  #print "dimensions of room: (" + str(a) + ", 0, " + str(b) + ")"
  #print "distance away: " + str(m)
  #print vx, vy, vz
  coordinates = (a/2.0, m, 0)
  steps = -1*m/float(vy)
  x_move = (steps*vx)%(2*a)
  z_move = (steps*vz)%(2*b)
  #print "x movement: " + str(x_move)
  #print "y movement: " + str(z_move)
  final_x = 0
  final_z = 0
  if x_move > a:
  	#print "x move is larger than dim"
  	x_move = x_move % a
  	final_x = a/2.0 + (a-x_move)
  else:
  	final_x = a/2.0 + x_move

  if z_move > b:
  	#print "z move is larger than dim"
  	z_move = z_move % b
  	final_z = (b-z_move)
  else:
  	final_z = z_move

  #while coordinates[1]

  print str(final_x) + " " + str(final_z)

  return

if __name__ == "__main__":
  main()

#!/usr/bin/python
import sys
import math

def main():
  lines = sys.stdin.readlines()
  a, b, m = map(int, lines.pop(0).split(' '))
  vx, vy, vz = map(int, lines.pop(0).split(' '))
  #print "dimensions of room: (" + str(a) + ", 0, " + str(b) + ")"
  #print "distance away: " + str(m)
  #print vx, vy, vz
  coordinates = (a/2.0, m, 0)
  steps = -1*m/float(vy)

  x_move = (steps*math.fabs(vx))%(2*a)
  z_move = (steps*vz)%(2*b)
  #print "x movement: " + str(x_move)
  #print "z movement: " + str(z_move)
  final_x = 0
  final_z = 0
  shifted = 0

  if x_move > a:
  	#print "x move is larger than dim"
  	x_move = x_move % a
  	final_x = a-x_move
  else:
    final_x = x_move
  #print final_x
  if (vx < 0):
    #shift a/2 to the left
    shifted = final_x - a/2.0
    if shifted < 0:
      shifted = -1*shifted
  else:
		#shift a/2 to the right
    shifted = final_x + a/2.0
    if shifted > a:
      shifted = 2*a - shifted
  #print "final x: " + str(shifted)

  if z_move > b:
  	#print "z move is larger than dim"
  	z_move = z_move % b
  	final_z = (b-z_move)
  else:
  	final_z = z_move
  print str(shifted) + " " + str(final_z)

if __name__ == "__main__":
  main()

a, b, m = map(float, raw_input().split())
vx, vy, vz = map(float, raw_input().split())
t = m / -vy
x = a / 2 + vx * t
z = vz * t
while x < 0:
	x += a
while x > a:
	x -= a
while z < 0:
	z += b
while z > b:
	z -= b
print x, z

import sys

a, b, m = map(float, sys.stdin.readline().split())
vx, vy, vz = map(float, sys.stdin.readline().split())

t = -m / vy
x = a / 2 + t * vx
z = t * vz

flag = 1;
while x > a or x < 0:
    if x > a: x -= a
    if x < 0: x += 1
    flag *= -1
if flag == -1: x = a - x

flag = 1;
while z > b:
    z -= b
    flag *= -1
if flag == -1: z = b - z

print x, z

def func(x,limit):
    while True:
        if(x < 0):
            x = -x
        elif (x > limit):
            x = 2.0*limit - x
        else:
            return x
text = raw_input()
a,b,m = map(int,text.split())
text = raw_input()
vx,vy,vz = map(int,text.split())
dx = a/2.0 + (m*1.0/-vy)*vx
dz = (m*1.0/-vy)*vz
print dx,dz
dx = func(dx,a)
dz = func(dz,b)
print "%.6f %.6f" % (dx,dz)