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.


-----Input-----

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. 


-----Output-----

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


-----Examples-----
Input
4 of week

Output
52

Input
30 of month

Output
11



-----Note-----

Polar 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.

Difficulty: EASY

Solutions:
(d, b, c) = input().split()
a = int(d)
if c == 'week':
	if a == 5 or a == 6:
		print('53')
	else:
		print('52')
elif a <= 29:
	print('12')
elif a == 30:
	print('11')
else:
	print('7')


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


__author__ = 'nikita'
day_in_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def month(x):
	cnt = 0
	for t in day_in_month:
		if t >= x:
			cnt += 1
	return cnt

def week(x):
	k = 51
	if x < 7:
		k += 1
	if x > 4:
		k += 1
	return k
a = input().strip()
spl = a.split()
if spl[2] == 'week':
	print(week(int(spl[0])))
if spl[2] == 'month':
	print(month(int(spl[0])))


from datetime import date, timedelta
in_ = input().split()
x = int(in_[0])
cur = date(2016, 1, 1)
ans = 0
while cur.year != 2017:
	if in_[2] == 'week':
		if x - 1 == cur.weekday():
			ans += 1
	elif in_[2] == 'month':
		if x == cur.day:
			ans += 1
	else:
		assert False
	cur += timedelta(1)
print(ans)


(a, b, c) = input().split()
if c == 'week':
	if a in ['6', '5']:
		print(53)
	else:
		print(52)
elif a == '31':
	print(7)
elif a == '30':
	print(11)
else:
	print(12)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(d, k, t) = str_array()
d = int(d)
if t == 'month':
	if d <= 29:
		print(12)
	elif d == 30:
		print(11)
	else:
		print(7)
elif d == 5 or d == 6:
	print(53)
else:
	print(52)


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


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


import math, string, itertools, fractions, heapq, collections, re, array, bisect
import datetime
import time
from sys import stdin, stdout
s = str(stdin.readline())
s = s.strip().lower()
c = ''
n = ''
if 'month' in s:
	c = 'M'
else:
	c = 'W'
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
	elif ct <= 28:
		return 12
	elif ct <= 30:
		return 10
	else:
		return 7
if c == 'M':
	ans = noofMOnths(2016, n)
else:
	ans = noofWeeks(2016, n)
stdout.write(str(ans) + '\n')


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)
elif d == 5 or d == 6:
	print(53)
else:
	print(52)


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)


def main():
	days = [-1, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	(n, _, t) = input().split()
	t = t[0]
	n = int(n)
	d = 5
	m = 1
	num = 1
	res = 0
	while True:
		if t == 'w' and d == n or (t == 'm' and num == n):
			res += 1
		d = d % 7 + 1
		num += 1
		if num > days[m]:
			num = 1
			m += 1
			if m == 13:
				break
	print(res)
main()


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
	elif 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)
main()


a = input().split()
if a[-1] == 'month':
	if a[0] == '31':
		print(7)
	elif a[0] == '30':
		print(11)
	else:
		print(12)
else:
	print(53 if a[0] in ('5', '6') else 52)


s = input().split()
(n, t) = (int(s[0]), s[2])
d = list(range(1, 30)) * 12
d += [30] * 11 + [31] * 7
if t == 'week' and (n == 5 or n == 6):
	print(53)
elif t == 'week':
	print(52)
else:
	print(d.count(n))


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


info = list((x for x in input().split()))
num = int(info[0])
if info[2] == 'week':
	if num == 5 or num == 6:
		print(53)
	else:
		print(52)
elif num == 30:
	print(11)
elif num == 31:
	print(7)
else:
	print(12)


s = input()
if s[-4:] == 'week':
	n = int(s[:-8])
	print(52 if n < 5 or n == 7 else 53)
else:
	n = int(s[:-9])
	if n < 30:
		print(12)
	elif n == 30:
		print(11)
	else:
		print(7)


from datetime import date
import calendar
(x, y, z) = map(str, input().split(' '))
year = 2016
count = 0
d = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
c = calendar.TextCalendar(calendar.SUNDAY)
if z == 'week':
	for m in range(1, 13):
		for i in c.itermonthdays(year, m):
			if i != 0:
				day = date(year, m, i)
				if day.weekday() == int(x) - 1:
					count += 1
elif z == 'month':
	for k in d:
		if int(x) <= k:
			count += 1
print(count)


(a, _, w) = input().split()
print([[[12, 52 + (a in '56')][len(w) < 5], 11][a == '30'], 7][a == '31'])


mon = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(x, f, t) = input().split()[:3]
x = int(x)
if t == 'week':
	(day, ans) = (4, 0)
	for i in range(366):
		ans += day % 7 + 1 == x
		day += 1
	print(ans)
else:
	ans = 0
	for e in mon:
		if e >= x:
			ans += 1
	print(ans)


s = input()
if s == '5 of week' or s == '6 of week':
	print('53', end='')
elif s == '1 of week' or s == '2 of week' or s == '3 of week' or (s == '4 of week') or (s == '7 of week'):
	print('52', end='')
elif s == '31 of month':
	(print('7', end=''),)
elif s == '30 of month':
	(print('11', end=''),)
else:
	(print('12', end=''),)


(n, s, s1) = input().split()
if s1 == 'week':
	a = [4, 5, 6, 7, 1, 2, 3]
	x = a[int(n) - 1]
	ans = 0
	while x <= 366:
		ans += 1
		x += 7
else:
	a = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	ans = 0
	for i in a:
		if int(n) <= i:
			ans += 1
print(ans)


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


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


s = input()
b = s.split(' ')
number = int(b[0])
days = 366
if b[2][0] == 'w':
	if number >= 5 and number != 7:
		print(53)
	else:
		print(52)
elif number <= 30:
	if number < 30:
		print(12)
	else:
		print(11)
else:
	print(7)


line = input().split()
num = int(line[0])
if line[2] == 'week':
	extra = 1 if num == 5 or num == 6 else 0
	print(str(52 + extra))
else:
	if num == 31:
		res = 7
	elif num == 30:
		res = 11
	else:
		res = 12
	print(str(res))


string = input().split(' ')
num = int(string[0])
if string[2] == 'month':
	if num == 31:
		print('7')
	elif num == 30:
		print('11')
	else:
		print('12')
elif num == 5 or num == 6:
	print('53')
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)
elif l[0] == '30':
	print(11)
elif l[0] == '31':
	print(7)
else:
	print(12)


a = input().split(' ')
m = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
(n, t, k) = (int(a[0]), a[2], 0)
if t == 'week':
	for i in range(366):
		if (i + 4) % 7 + 1 == n:
			k += 1
else:
	for i in m:
		if i >= n:
			k += 1
print(k)


(a, b, c) = input().split()
if c == 'week':
	print(52 + (a in '56'))
else:
	a = int(a)
	print(12 if a in range(1, 30) else 11 if a == 30 else 7)


weeks = [52, 52, 52, 52, 53, 53, 52]
months = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 7]
s = list(input().split(' '))
no = int(s[0])
if s[2] == 'week':
	print(weeks[no - 1])
else:
	print(months[no - 1])


l = list(map(str, input().split()))
if l[2] == 'month':
	if int(l[0]) <= 29:
		print(12)
	if int(l[0]) == 30:
		print(11)
	if int(l[0]) == 31:
		print(7)
else:
	x = int(l[0])
	if x >= 1 and x <= 4 or x == 7:
		print(52)
	if x == 5 or x == 6:
		print(53)


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


s = input().split()
k = 0
if len(s[0]) == 1:
	k = ord(s[0]) - 48
else:
	k = (ord(s[0][0]) - 48) * 10 + ord(s[0][1]) - 48
if s[2] == 'month':
	if k <= 29:
		print(12)
	elif k == 30:
		print(11)
	else:
		print(7)
elif k == 5 or k == 6:
	print(53)
else:
	print(52)


import pprint
import os
import json
import re
import argparse
import random
a = input().split()
d = {'week': [52] * 5 + 2 * [53] + [52], 'month': 30 * [12] + [11] + [7]}
print(d[a[2]][int(a[0])])


x = input().split()
if x[2] == 'week':
	print(53 if 4 < int(x[0]) < 7 else 52)
else:
	print(7 if x[0] == '31' else 11 if x[0] == '30' else 12)


(num, _, period) = input().split()
num = int(num)
if period == 'month':
	print(12 if num < 30 else 11 if num < 31 else 7)
elif period == 'week':
	print(52 if num < 5 or num == 7 else 53)


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


(a, b, c) = input().split()
if 'w' in c:
	print(52 + (a in '56'))
else:
	print(7 if a == '31' else 11 if a == '30' else 12)


weeks = [52, 52, 52, 52, 53, 53, 52]
days_in_months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(day, *trash, period) = input().split()
day = int(day)
if period == 'week':
	print(weeks[day - 1])
elif period == 'month':
	months = 0
	for days in days_in_months:
		if day <= days:
			months += 1
	print(months)


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


raw = input().split()
(x, s) = (int(raw[0]), raw[2] == 'month')
if s:
	out = 12
	if x > 29:
		out -= 1
	if x > 30:
		out -= 4
	print(out)
else:
	print([52, 52, 52, 52, 53, 53, 52][x - 1])


mnthnums = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def of_month(n):
	ans = 0
	for i in range(12):
		if mnthnums[i] >= n:
			ans += 1
	return ans

def of_week(n):
	if n >= 5:
		n -= 4
	else:
		n += 2
	return (366 - n + 7) // 7
strs = input().split()
n = int(strs[0])
if strs[-1] == 'week':
	print(of_week(n))
else:
	print(of_month(n))


s = str(input()).split()
x = int(s[0])
typeOf = str(s[2])
N = 366
if typeOf == 'week':
	if x == 1:
		x = 4
	elif x == 2:
		x = 5
	elif x == 3:
		x = 6
	elif x == 4:
		x = 7
	elif x == 5:
		x = 1
	elif x == 6:
		x = 2
	elif x == 7:
		x = 3
	else:
		print('Never happens.')
	a = N // 7
	b = N % 7
	if x <= b:
		a += 1
	print(a)
elif 1 <= x <= 29:
	print(12)
elif x == 30:
	print(11)
else:
	print(7)


data = input().split()
if data[-1] == 'week':
	data = int(data[0]) - 4
	if data <= 0:
		data += 7
	result = 366 // 7
	if data <= 366 % 7:
		result += 1
	print(result)
elif data[-1] == 'month':
	data = int(data[0])
	if data <= 29:
		print(12)
	elif data == 30:
		print(11)
	elif data == 31:
		print(7)


from datetime import timedelta, date
start_date = date(2016, 1, 1)
end_date = date(2017, 1, 1)
(check, o, t) = input().split()
weekday = t == 'week'
check = int(check) - int(weekday)
c = 0

def daterange(start_date, end_date):
	for n in range(int((end_date - start_date).days)):
		yield (start_date + timedelta(n))
for a in daterange(start_date, end_date):
	if weekday and a.weekday() == check:
		c += 1
	elif not weekday and a.day == check:
		c += 1
print(c)


from operator import itemgetter
s = input().split()
if len(s[2]) == 5:
	if s[0] == '30':
		print(11)
	elif s[0] == '31':
		print(7)
	else:
		print(12)
elif s[0] == '6' or s[0] == '5':
	print(53)
else:
	print(52)


plan = input().split()
jan = 31
feb = 29
march = 31
april = 30
may = 31
june = 30
july = 31
auguest = 31
sep = 30
oct = 31
nov = 30
dec = 31
if plan[2] == 'week':
	if plan[0] == '1' or plan[0] == '2' or plan[0] == '3' or (plan[0] == '4') or (plan[0] == '7'):
		print(52)
	else:
		print(53)
if plan[2] == 'month':
	if plan[0] == '30':
		print(11)
	elif plan[0] == '31':
		print(7)
	else:
		print(12)


a = input().split()
b = int(a[0])
if a[2] == 'week':
	if b >= 5 and b <= 6:
		print(53)
	else:
		print(52)
elif b == 31:
	print(7)
elif b == 30:
	print(11)
else:
	print(12)


inp = input().split()
if inp[2] == 'week':
	week = int(inp[0]) - 1
	table = [52, 52, 52, 52, 53, 53, 52]
	ans = table[week]
else:
	month = int(inp[0]) - 1
	table = [12] * 29 + [11, 7]
	ans = table[month]
print(ans)


S = input().split()
a = int(S[0])
S1 = S[2]
k = 0
if S1 == 'month':
	if a == 31:
		print(7)
	if a > 29 and a < 31:
		print(11)
	if a <= 29:
		print(12)
else:
	i = 5
	j = 365
	while a != i:
		i = i + 1
		j = j - 1
		if i == 8:
			i = 1
	while j >= 0:
		j = j - 7
		k = k + 1
	print(k)


days_in_month = map(int, '31 29  31  30  31  30  31  31  30  31  30  31'.split())
s = input().split()
n = int(s[0])
if s[2] == 'month':
	ans = 0
	for el in days_in_month:
		if n <= el:
			ans += 1
	print(ans)
elif n in [5, 6]:
	print(53)
else:
	print(52)


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


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)
elif a <= 29:
	print(12)
elif a == 30:
	print(11)
elif a == 31:
	print(7)


(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)


(sn, _, mw) = input().split()
n = int(sn)
res = 0
if mw == 'month':
	if n == 31:
		res = 7
	elif n == 30:
		res = 11
	else:
		res = 12
else:
	res = 52 + (n == 5 or n == 6)
print(res)


(x, s1, s2) = input().split()
x = int(x)
if s2 == 'month':
	if x <= 29:
		ans = 12
	if x == 30:
		ans = 11
	if x == 31:
		ans = 7
else:
	if 1 <= x <= 4:
		ans = 52
	if 5 <= x <= 6:
		ans = 53
	if x == 7:
		ans = 52
print(ans)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
d = {1: 52, 2: 52, 3: 52, 4: 52, 5: 53, 6: 53, 7: 52}
s = get_string().split()
n = int(s[0])
if s[2] == 'week':
	print(d[n])
elif n <= 29:
	print(12)
elif n == 30:
	print(11)
else:
	print(7)


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


def month(a):
	return {'31': 7, '30': 11}.get(a, 12)

def week(a):
	return {'5': 53, '6': 53}.get(a, 52)
(a, b, s) = input().split()
if s == 'month':
	print(month(a))
else:
	print(week(a))


s = input().split()
l1 = [52, 52, 52, 52, 53, 53, 52]
l2 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
count = 0
if s[2] == 'month':
	x = int(s[0])
	for i in range(len(l2)):
		if x <= l2[i]:
			count += 1
	print(count)
else:
	for i in range(len(l1)):
		if int(s[0]) == i + 1:
			print(l1[i])
			break


n = list(map(str, input().split()))
if 'week' in n:
	if '6' in n or '5' in n:
		print('53')
	else:
		s = int(365 / int(7))
		print(s)
if 'month' in n:
	if '30' in n:
		print('11')
	elif '31' in n:
		print('7')
	else:
		print('12')


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()
x = int(s[0:2])
s = s[2:]
if s == 'of week':
	if x == 5:
		print('53')
	elif x == 6:
		print('53')
	else:
		print('52')
elif x == 31:
	print('7')
elif x == 30:
	print('11')
else:
	print('12')


l = list(input().split())
table = {0: 52, 1: 52, 2: 52, 3: 52, 4: 52, 5: 53, 6: 53}
if l[2] == 'week':
	print(table[int(l[0]) % 7])
else:
	n = int(l[0])
	if n <= 29:
		print(12)
	elif n > 30:
		print(7)
	else:
		print(11)


(num, of, x) = input().split()
num = int(num)
if x == 'month':
	print(12 if num <= 29 else 11 if num == 30 else 7)
else:
	print(53 if 5 <= num <= 6 else 52)


fl = 0
tr = 1
d = 0
a = ''
ws = [0, 52, 52, 52, 52, 53, 53, 52]
a = input()
if a[5] == 'w':
	fl = 1
if fl == 0:
	if a[1] != ' ':
		tr = 2
	d = int(a[0:tr])
	if d == 30:
		print(11)
	elif d == 31:
		print(7)
	else:
		print(12)
else:
	d = int(a[0:tr])
	print(ws[d])


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)


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


x = input().split(' ')
if x[-1] == 'week':
	if x[0] == '5' or x[0] == '6':
		print(53)
	else:
		print(52)
elif x[0] == '31':
	print(7)
elif x[0] == '30':
	print(11)
else:
	print(12)


s = input().split()
s[0] = int(s[0])
if s[2][0] == 'w':
	if s[0] in [1, 2, 3, 4, 7]:
		print(52)
	else:
		print(53)
elif s[0] <= 29:
	print(12)
elif s[0] == 30:
	print(11)
else:
	print(7)


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


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


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


line = str(input())
x = int(line.split()[0])
if line.endswith('week'):
	if x == 5 or x == 6:
		print(53)
	else:
		print(52)
elif line.endswith('month'):
	if x == 31:
		print(7)
	elif x == 30:
		print(11)
	else:
		print(12)


str = list(input().split())
months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
weeks = [52, 52, 52, 52, 53, 53, 52]
if str[2] == 'week':
	print(weeks[int(str[0]) - 1])
else:
	cnt = 0
	for days in months:
		if days >= int(str[0]):
			cnt += 1
	print(cnt)


l = [*map(str, input().split())]
if l[2][0] == 'w':
	print(53 if int(l[0]) in [6, 5] else 52)
else:
	a = int(l[0])
	if a in [30]:
		print(11)
	elif a == 31:
		print(7)
	else:
		print(12)


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


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


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


s = input().split()
M = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if s[-1] == 'month':
	x = int(s[0])
	ans = 0
	for i in range(12):
		if M[i] >= x:
			ans += 1
	print(ans)
else:
	x = int(s[0])
	cur = 5
	ans = 0
	for i in range(366):
		if cur == x:
			ans += 1
		cur += 1
		cur = (cur - 1) % 7 + 1
	print(ans)


def month(n):
	if n == 31:
		return 7
	if n == 30:
		return 11
	else:
		return 12

def week(n):
	if n == 1:
		return 52
	if n == 2:
		return 52
	if n == 3:
		return 52
	if n == 4:
		return 52
	if n == 5:
		return 53
	if n == 6:
		return 53
	if n == 7:
		return 52
tp = str(input()).split()
if tp[2] == 'week':
	print(week(int(tp[0])))
else:
	print(month(int(tp[0])))


import sys
S = input()
if S == '1 of week':
	print(52)
if S == '2 of week':
	print(52)
if S == '3 of week':
	print(52)
if S == '4 of week':
	print(52)
if S == '5 of week':
	print(53)
if S == '6 of week':
	print(53)
if S == '7 of week':
	print(52)
for i in range(1, 30):
	if S == str(i) + ' of month':
		print(12)
if S == '30 of month':
	print(11)
if S == '31 of month':
	print(7)


def month(a):
	if a <= 29:
		return 12
	if a <= 30:
		return 11
	if a <= 31:
		return 7
	return 0

def week(a):
	if a <= 4:
		return 52
	if a < 7:
		return 53
	if a == 7:
		return 52
	return 0

def main():
	(arg1, _, mode) = input().split()
	arg1 = int(arg1)
	if mode == 'week':
		print(week(arg1))
	else:
		print(month(arg1))
main()


x = input().split()
y = int(x[0])
if x[2] == 'week':
	if y >= 5 and y <= 6:
		print(53)
	else:
		print(52)
elif y == 31:
	print(7)
elif y == 30:
	print(11)
else:
	print(12)


x = input('').split(' ')
if x[2] == 'month':
	f = int(x[0])
	days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	cnt = 0
	for g in days:
		if g >= f:
			cnt += 1
	print(cnt)
else:
	f = int(x[0])
	if f == 6:
		print(53)
	elif f == 7:
		print(52)
	elif f == 5:
		print(53)
	elif f == 4:
		print(52)
	elif f == 3:
		print(52)
	elif f == 2:
		print(52)
	elif f == 1:
		print(52)


def solve():
	(n, of, type) = input().split()
	n = int(n)
	if type == 'month':
		if n <= 29:
			print(12)
		elif n <= 30:
			print(11)
		else:
			print(7)
	elif n <= 4 or n == 7:
		print(52)
	else:
		print(53)
solve()


s = input().split()
dict = {'week': 5 * [52] + 2 * [53] + [52], 'month': 30 * [12] + [11, 7]}
print(dict[s[2]][int(s[0])])


(n, _, s) = input().split()
print([[[12, 52 + (n in '56')][s > 'n'], 11][n == '30'], 7][n == '31'])


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


def solve(s):
	m = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	if 'month' in s:
		return sum([1 for i in m if i >= int(s.split()[0])])
	else:
		a = int(s[0])
		x = sum(m) - 3
		return x // 7 + (1 if a <= x % 7 else 0) + (1 if 5 <= a <= 7 else 0)

def main():
	s = input()
	print(solve(s))
main()


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


from datetime import date
from datetime import timedelta

def calculateWeek(Day):
	Day = Day - 1
	sDays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
	stDay = date(2016, 1, 1)
	edDay = date(2016, 12, 31)
	cDate = stDay
	y = 1
	while stDay.strftime('%a') != sDays[Day]:
		stDay = stDay + timedelta(days=1)
	while stDay < edDay:
		stDay = stDay + timedelta(days=7)
		y = y + 1
	if int(stDay.strftime('%Y')) > 2016:
		y = y - 1
	print(y)

def calculateMonth(Day):
	y = 0
	for x in [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]:
		if Day <= x:
			y = y + 1
	print(y)
strinput = input()
if strinput.find('of week') > 0:
	calculateWeek(int(strinput.split(' ')[0]))
else:
	calculateMonth(int(strinput.split(' ')[0]))


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


x = [i for i in input().split()]
if x[2] == 'week':
	print(53 if int(x[0]) in [5, 6] else 52)
elif int(x[0]) == 31:
	print(7)
elif int(x[0]) == 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) <= 29 else 11 if int(ind) <= 30 else 7)


k = input().split(' of ')
if k[1] == 'week':
	print([52, 53][k[0] == '5' or k[0] == '6'])
elif int(k[0]) < 31:
	print([11, 12][int(k[0]) <= 29])
else:
	print(7)


(a, b, c) = input().split()
x = [52, 52, 52, 52, 53, 53, 52]
if c == 'week':
	print(x[int(a) - 1])
elif int(a) == 31:
	print(7)
elif int(a) == 30:
	print(11)
else:
	print(12)


(x, _, ty) = input().split()
x = int(x)
Mons = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(day, month, week) = (0, 0, 4)
x -= 1
ans = 0
for t in range(366):
	if ty == 'week':
		ans += x == week
	else:
		ans += day == x
	day += 1
	week += 1
	if week == 7:
		week = 0
	if day == Mons[month]:
		month += 1
		day = 0
print(ans)


s = input()
if s[-5] == 'm':
	if int(s[0:2]) >= 1 and int(s[0:2]) <= 29:
		print(12)
	elif int(s[0:2]) == 30:
		print(11)
	else:
		print(7)
else:
	week = [0, 52, 52, 52, 52, 53, 53, 52]
	print(week[int(s[0:2])])


inputty = input()
num = int(inputty.split(' ')[0])
if 'week' in inputty:
	if num <= 4 or num == 7:
		print(52)
	else:
		print(53)
elif num <= 29:
	print(12)
elif num == 30:
	print(11)
else:
	print(7)


s = input()
try:
	if int(s[0:2]):
		a = int(s[0:2])
except:
	if int(s[0:1]):
		a = int(s[0:1])
if 'week' in s:
	if a == 5 or a == 6:
		print(53)
	else:
		print(52)
elif a == 31:
	print(7)
elif a == 30:
	print(11)
else:
	print(12)


s = input().split(' ')
n = int(s[0])
if s[-1] == 'month':
	ans = 12 - 5 * int(n == 31) - 1 * int(n == 30)
elif s[-1] == 'week':
	ans = 52 + int(5 <= n <= 6)
print(ans)


import sys
(x, m, b) = [i for i in input().split(' ')]
x = int(x)
if b == 'week':
	if x == 5 or x == 6:
		print(53)
	else:
		print(52)
elif x == 31:
	print(7)
elif x == 30:
	print(11)
else:
	print(12)


s = input().split()
if s[-1] == 'month':
	if s[0] == '31':
		print('7')
	elif s[0] == '30':
		print('11')
	else:
		print('12')
elif s[0] in '12347':
	print('52')
elif s[0] in '56':
	print('53')


i = input()
n = ''
for char in i:
	if char == ' ':
		break
	n += char
n = int(n)
if i[-1] == 'k':
	if abs(n - 5.5) < 1:
		print(53)
	else:
		print(52)
elif n == 31:
	print(7)
elif n == 30:
	print(11)
else:
	print(12)


week = [52] * 4 + [53] * 2 + [52]
month = [12] * 29 + [11] + [7]
ans = {'week': week, 'month': month}
(a, b, c) = input().split()
print(ans[c][int(a) - 1])


def from_week(value):
	return 52 if value in [1, 2, 3, 4, 7] else 53

def from_month(value):
	return 12 if value <= 29 else 11 if value <= 30 else 7

def main():
	[value, type] = input().split(' of ')
	print(from_week(int(value)) if type == 'week' else from_month(int(value)) if type == 'month' else 0)
main()


(n, s, s) = list(input().split(' '))
n = int(n)
if s == 'week':
	print(52 + (1 if n == 5 or n == 6 else 0))
else:
	print(12 - (1 if n == 30 else 0) - (5 if n == 31 else 0))


from datetime import *
d = date(2016, 1, 1)
n = input().split()
r = 0
if n[-1] == 'week':
	n = int(n[0]) - 1
	while d.year == 2016:
		if d.weekday() == n:
			r += 1
		d += timedelta(days=1)
else:
	n = int(n[0])
	while d.year == 2016:
		if d.day == n:
			r += 1
		d += timedelta(days=1)
print(r)


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


a = list(map(str, input().split()))
d = int(a[0])
if a[-1] == 'month':
	if d <= 29:
		print(12)
	elif d > 30:
		print(7)
	else:
		print(11)
else:
	print(53 if 4 < d < 7 else 52)


x = list(map(str, input().split()))
week = [52, 52, 52, 52, 53, 53, 52]
if x[2] == 'week':
	print(week[int(x[0]) - 1])
elif int(x[0]) <= 29:
	print(12)
elif int(x[0]) == 31:
	print(7)
else:
	print(11)


day_of_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
first_day = 5
(x, of, y) = input().split()
x = int(x)
if y == 'week':
	x = x % 7
z = 0
k = first_day
for i in range(12):
	for j in range(day_of_month[i]):
		if y == 'week':
			if k == x:
				z += 1
		elif y == 'month':
			if j + 1 == x:
				z += 1
		k = (k + 1) % 7
print(z)


from datetime import *
(x, of, y) = input().split(' ')
x = int(x)
d = timedelta(days=1)
t = datetime(2016, 1, 1)
c = 0
while t.year == 2016:
	if y == 'week' and t.weekday() == x - 1 or (y == 'month' and t.day == x):
		c += 1
	t += d
print(c)


import re, sys, math, string, operator, functools, fractions, collections
sys.setrecursionlimit(10 ** 7)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
RI = lambda : list(map(int, input().split()))
RS = lambda : input().rstrip().split()
s = RS()
if s[-1] == 'month':
	if s[0] == '30':
		ans = 11
	elif s[0] == '31':
		ans = 7
	else:
		ans = 12
else:
	ans = 52 + (s[0] == '5' or s[0] == '6')
print(ans)


l = list(map(str, input().split()))
if l[2] == 'week':
	m = 52
	if int(l[0]) == 5 or int(l[0]) == 6:
		m = 53
elif l[2] == 'month':
	if int(l[0]) <= 29:
		m = 12
	elif int(l[0]) == 30:
		m = 11
	else:
		m = 7
print(m)


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


n = input()
l = list(n.strip().split())
k = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29']
if l[-1] == 'week':
	if l[0] == '1' or l[0] == '2' or l[0] == '3' or (l[0] == '4') or (l[0] == '7'):
		print(52)
	elif l[0] == '5' or l[0] == '6':
		print(53)
if l[-1] == 'month':
	if l[0] in k:
		print(12)
	elif l[0] == '30':
		print(11)
	elif l[0] == '31':
		print(7)


s = input()
if s[-1] == 'h':
	r = int(s.split()[0])
	if r <= 29:
		print(12)
	elif r == 30:
		print(11)
	else:
		print(7)
else:
	r = int(s.split()[0])
	if r <= 4:
		print(52)
	elif r <= 6:
		print(53)
	else:
		print(52)


n = input()
m = list(n)
y = int(m[0])
if 'of week' in n:
	if y == 1 or y == 2 or y == 3 or (y == 4) or (y == 7):
		print(52)
	if y == 5 or y == 6:
		print(53)
else:
	x = m[0]
	z = m[0] + m[1]
	if x is True:
		y = int(x)
	else:
		y = int(z)
		if 'of month' in n:
			if y == 31:
				print(7)
			elif y == 30:
				print(11)
			elif y == 29:
				print(12)
			else:
				print(12)


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


a = input().split()
if a[0] == '31':
	print(7)
	exit()
if a[0] == '30':
	print(11)
	exit()
if a[2] == 'month':
	print(12)
	exit()
if a[0] == '5' or a[0] == '6':
	print(53)
	exit()
print(52)


s = input()
if 'week' in s:
	x = int(s[:1])
	if x == 6 or x == 5:
		print(53)
	else:
		print(52)
else:
	x = int(s[:2])
	if x <= 29:
		print(12)
	elif x == 30:
		print(11)
	else:
		print(7)


(a, b, c) = map(str, input().split())
a = int(a)
b = '5,6,7,1,2,3,4'
b = 53 * b
p = [int(i) for i in b if i.isdigit()]
p = p[:366]
if c == 'week':
	print(p.count(a))
elif a <= 29:
	print(12)
elif a == 30:
	print(11)
else:
	print(7)


month = {1: 31, 2: 29, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
week = {1: 52, 2: 52, 3: 52, 4: 52, 5: 53, 6: 53, 7: 52}
inputs = input().split()
if inputs[2] == 'week':
	print(week[int(inputs[0])])
elif inputs[2] == 'month':
	day = int(inputs[0])
	res = 0
	for i in range(1, len(month) + 1):
		if day <= month[i]:
			res += 1
	print(res)


import time
(n, _, flag) = (i for i in input().split())
n = int(n)
start = time.time()
if flag == 'month':
	if n < 30:
		ans = 12
	elif n == 30:
		ans = 11
	else:
		ans = 7
else:
	ans = 52
	if n == 5 or n == 6:
		ans += 1
print(ans)
finish = time.time()


n = list(input().split(' '))
if n[len(n) - 1] == 'week':
	p = int(n[0])
	if p in [1, 2, 3, 4, 7]:
		print(52)
	elif p in [5, 6]:
		print(53)
elif n[len(n) - 1] == 'month':
	q = int(n[0])
	if q == 30:
		print(11)
	elif q == 31:
		print(7)
	elif 1 <= q <= 29:
		print(12)


month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = 366
l = list(input().split())
l[0] = int(l[0])
cnt = 0
if l[2] == 'month':
	for x in month:
		if x >= l[0]:
			cnt += 1
else:
	for i in range(4, days + 4):
		if i % 7 == l[0] - 1:
			cnt += 1
print(cnt)


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')
elif x == 30:
	print('11')
elif x == 31:
	print('7')
else:
	print('12')


line = str(input())
if line[-1] == 'k':
	if line[0] == '1':
		print(52)
	elif line[0] == '2':
		print(52)
	elif line[0] == '3':
		print(52)
	elif line[0] == '4':
		print(52)
	elif line[0] == '5':
		print(53)
	elif line[0] == '6':
		print(53)
	elif line[0] == '7':
		print(52)
a = int(line[0] + line[1])
if line[-1] == 'h':
	if a <= 29:
		print(12)
	elif a == 30:
		print(11)
	else:
		print(7)


s = input().split()
x = int(s[0])
if s[2][0] == 'w':
	if x >= 5 and x < 7:
		print(52 + 1)
	else:
		print(52)
elif x <= 29:
	print(12)
elif x == 30:
	print(11)
else:
	print(7)


(a, b, c) = input().split()
a = int(a)
l = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if c[0] == 'w':
	i = 1
	ans = 0
	current = 5
	while i <= 366:
		if current == a:
			ans += 1
		current += 1
		if current > 7:
			current = 1
		i += 1
	print(ans)
elif a == 30:
	print('11')
elif a == 31:
	print('7')
else:
	print('12')


s = list(input().split())
if 'week' in s:
	if int(s[0]) == 5 or int(s[0]) == 6:
		print(53)
	else:
		print(52)
if 'month' in s:
	if int(s[0]) < 30:
		print(12)
	elif int(s[0]) == 30:
		print(11)
	else:
		print(7)


a = input().split()
x = int(a[0])
if a[2] == 'month':
	if x == 31:
		print(7)
	elif x == 30:
		print(11)
	else:
		print(12)
else:
	t = 51
	if 4 < x < 8:
		t += 1
	if 0 < x < 7:
		t += 1
	print(t)


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


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


String = input()
if String[-5:] == 'month':
	if int(String[0:2]) <= 29:
		print(12)
	elif int(String[0:2]) == 30:
		print(11)
	elif int(String[0:2]) == 31:
		print(7)
elif int(String[0:1]) <= 4 or int(String[0:1]) == 7:
	print(52)
else:
	print(53)


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 == 5:
		print(53)
	else:
		print(52)
else:
	print(12)


def main():
	(x, _, w) = input().split()
	x = int(x)
	if w == 'week':
		print((366 + x) // 7 - x // 7)
	else:
		print(7 + 4 * (x < 31) + (x < 30))
main()


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
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)
elif v == 30:
	print(11)
elif v == 31:
	print(7)
else:
	print(12)


def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[a, b, c] = input().split()
	a = int(a)
	if c == 'month':
		if a >= 1 and a < 30:
			print('12')
		elif a == 30:
			print('11')
		else:
			print('7')
	elif a < 5 or a == 7:
		print('52')
	else:
		print('53')
	if mode == 'file':
		f.close()
main()


s = input().split()
a = int(s[0])
if s[-1] == 'week':
	if a == 6 or a == 5:
		print(53)
	else:
		print(52)
elif a > 29:
	if a == 31:
		print(7)
	else:
		print(11)
else:
	print(12)


import datetime
cur = datetime.date(2016, 1, 1)
day = datetime.timedelta(days=1)
l = input().split()
hit = int(l[0])
assert l[2] in ['week', 'month']
month = l[2] == 'month'
tot = 0
while cur.year == 2016:
	if month:
		if cur.day == hit:
			tot += 1
	elif cur.isoweekday() == hit:
		tot += 1
	cur += day
print(tot)


(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)
elif a == 31:
	print(7)
elif a == 30:
	print(11)
else:
	print(12)


s = input().split()
if s[-1] == 'week':
	n = int(s[0])
	id = int(5)
	ans = [int(0)] * 8
	for i in range(366):
		ans[id] += 1
		id += 1
		if id > 7:
			id = 1
	print(ans[n])
else:
	ans = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	n = int(s[0])
	ret = 0
	for i in ans:
		if n <= i:
			ret += 1
	print(ret)


import datetime
d = datetime.date(2016, 1, 1)
v = input().split()
ans = 0
while True:
	if d.year != 2016:
		break
	if v[2] == 'week' and int(v[0]) == d.isoweekday():
		ans += 1
	if v[2] == 'month' and int(v[0]) == d.day:
		ans += 1
	d = d + datetime.timedelta(days=1)
print(ans)


s = input().split()
num = int(s[0])
if s[-1] == 'week':
	if num in (5, 6):
		print(53)
	else:
		print(52)
elif num < 30:
	print(12)
elif num == 30:
	print(11)
elif num == 31:
	print(7)


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


'__author__' == 'deepak Singh Mehta(learning to code :) ) '
(date, of, param) = map(str, input().split())
date = int(date)
if param[0] == 'w':
	if date == 5 or date == 6:
		print(53)
	else:
		print(52)
elif date <= 29:
	print(12)
elif date <= 30:
	print(11)
else:
	print(7)


l = [0, 52, 52, 52, 52, 53, 53, 52]
m = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(a, b, c) = map(str, input().split())
if c == 'week':
	print(l[int(a)])
if c == 'month':
	count = 0
	for i in range(len(m)):
		if int(a) in range(1, m[i] + 1):
			count += 1
	print(count)


def main():
	(number, of, quantifier) = input().split()
	number = int(number)
	months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	weeks = {'mon': 1, 'tue': 2, 'wed': 3, 'thu': 4, 'fri': 5, 'sat': 6, 'sun': 7}
	if quantifier == 'month':
		total = sum((1 for month in months if number <= month))
	elif quantifier == 'week':
		total = 53 if number == weeks['fri'] or number == weeks['sat'] else 52
	print(total)
main()


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


ip = input().split()
num = int(ip[0])
start = 5
if ip[2] == 'week':
	if num == 5 or num == 6:
		print(53)
	else:
		print(52)
else:
	month_len = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	c = 0
	for i in month_len:
		if num <= i:
			c += 1
	print(c)


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


inp = input().split()
if inp[2] == 'week':
	ans = 51
	if inp[0] in '567':
		ans += 1
	if inp[0] in '123456':
		ans += 1
	print(ans)
else:
	x = int(inp[0])
	ans = 7
	if x <= 29:
		ans += 1
	if x <= 30:
		ans += 4
	print(ans)


a = input().split()
n = int(a[0])
j = a[len(a) - 1]
if j == 'month':
	if n == 31:
		print(7)
	elif n == 30:
		print(11)
	else:
		print(12)
elif j == 'week':
	if n == 6 or n == 5:
		print(53)
	else:
		print(52)


s = list(input().split())
s[0] = int(s[0])
w = [0, 52, 52, 52, 52, 53, 53, 52]
if s[2] == 'week':
	print(w[s[0]])
elif s[0] <= 29:
	print(12)
elif s[0] == 30:
	print(11)
else:
	print(7)


s = input()
w = s.split()
m = int(w[0])
if 'month' in s:
	if 1 <= m and m <= 29:
		print(12)
	elif m == 30:
		print(11)
	else:
		print(7)
elif 1 <= m and m <= 4 or m == 7:
	print(52)
else:
	print(53)


a = ''
a += input()
k = a[0] + a[1]
if a.find('week') > -1:
	if a[0] != '6' and a[0] != '5':
		print(52)
	else:
		print(53)
elif int(k) <= 29:
	print(12)
elif int(k) == 30:
	print(11)
else:
	print(7)


(a, b, c) = map(str, input().split())
if c == 'month' and int(a) <= 29:
	print(12)
elif c == 'month' and int(a) == 30:
	print(11)
elif c == 'month' and int(a) == 31:
	print(7)
elif c == 'week' and a == '5':
	print(53)
elif c == 'week' and a == '6':
	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)
elif i == 5 or i == 6:
	print(53)
else:
	print(52)


a = input()
arr = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
f = int(a.split(' ')[0])
count = 0
if a.split(' ')[2] == 'month':
	for i in arr:
		if f <= i:
			count += 1
	print(count)
else:
	print(53 if f == 5 or f == 6 else 52)


p = input().split()
n = int(p[0])
a = 366
if p[2] == 'week':
	if n >= 5:
		print((a - (n - 5) + 6) // 7)
	else:
		print((a - 2 - n + 6) // 7)
elif n > 29:
	if n == 30:
		print(11)
	if n == 31:
		print(7)
else:
	print(12)


ins = input().split()
dict = {'week': [0, 52, 52, 52, 52, 53, 53, 52], 'month': 30 * [12] + [11, 7]}
print(dict[ins[2]][int(ins[0])])


x = input()
y = ' '
a = x.split(y)
if a[2] == 'month':
	if int(a[0]) < 30:
		print('12')
	elif a[0] == '30':
		print('11')
	elif a[0] == '31':
		print('7')
if a[2] == 'week':
	if a[0] == '5' or a[0] == '6':
		print('53')
	elif int(a[0]) < 4 or a[0] == '7' or a[0] == '4':
		print('52')


a = input()
if a[-1] == 'h':
	month = True
	week = False
else:
	month = False
	week = True
x = int(a[0] + a[1])
if month:
	if x <= 29:
		print(12)
	elif x == 30:
		print(11)
	else:
		print(7)
elif x < 5 or x == 7:
	print(52)
else:
	print(53)


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)


INPUT = input()
number = int(INPUT.split()[0])
option = INPUT.split()[2]
result = 0
if option == 'week':
	result = 52
	if number == 5 or number == 6:
		result += 1
if option == 'month':
	result = 12
	if number == 30:
		result -= 1
	if number == 31:
		result -= 5
print(result)


(a, bfuck, b) = map(str, input().split(' '))
a = int(a)
if b == 'week':
	if a == 5 or a == 6:
		print('53')
	else:
		print('52')
elif a <= 29:
	print('12')
elif a == 30:
	print('11')
else:
	print('7')


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


s = input()
number = int(s[0])
if s[1] != ' ':
	number *= 10
	number += int(s[1])
another = s[len(s) - 5:]
if another == 'month':
	if number <= 29:
		print(12)
	elif number == 30:
		print(11)
	else:
		print(7)
elif number == 5 or number == 6:
	print(53)
else:
	print(52)


ch = str(input())
n = len(ch)
t = ch[n - 1]
e = ch.index(' ')
m = int(ch[:e])
if t == 'k':
	if m == 5 or m == 6:
		print(53)
	else:
		print(52)
elif m <= 29:
	print(12)
elif m == 30:
	print(11)
elif m == 31:
	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)
elif 7 > x > 4:
	print(53)
else:
	print(52)


(n, _, t) = input().split()
n = int(n)
if t == 'month':
	print(sum([1 for x in [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] if n <= x]))
else:
	sol = 53
	if n == 7:
		sol -= 1
	if n < 5:
		sol -= 1
	print(sol)


saving_plan = input().split()
(day, course) = (int(saving_plan[0]), saving_plan[2])
if course == 'week':
	if day == 7 or day <= 4:
		print('52')
	else:
		print('53')
if course == 'month':
	if day == 31:
		print('7')
	elif day == 30:
		print('11')
	else:
		print('12')


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = inp()
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	tokens = input().split()
	day = int(tokens[0])
	t_type = tokens[2]
	if t_type == 'week':
		if day in (5, 6):
			print(53)
		else:
			print(52)
	elif day <= 29:
		print(12)
	elif day == 30:
		print(11)
	else:
		print(7)


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


__author__ = 'Utena'
n = input().split()
if n[2] == 'week':
	n = int(n[0])
	if n == 5 or n == 6:
		print(53)
	else:
		print(52)
else:
	n = int(n[0])
	total = 0
	for i in range(1, 13):
		if i in (1, 3, 5, 7, 8, 10, 12):
			total += 1
		elif i in (4, 6, 9, 11):
			if n <= 30:
				total += 1
		elif n <= 29:
			total += 1
	print(total)


months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = {'1': 52, '2': 52, '3': 52, '4': 52, '5': 53, '6': 53, '7': 52}
line = input()
data = line.split(' ')
if data[2] == 'month':
	count = 0
	num = int(data[0])
	for i in months:
		if i >= num:
			count += 1
	print(count)
else:
	print(days[data[0]])


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


import datetime
s = input()
(sx, *_) = str.split(s)
x = int(sx)
d = datetime.date(2016, 1, 1)
dt = datetime.timedelta(days=1)
if 'week' in s:
	cond = lambda d: d.isoweekday() == x
else:
	cond = lambda d: d.day == x
count = 0
while d < datetime.date(2017, 1, 1):
	if cond(d):
		count += 1
	d += dt
print(count)


s = list(map(str, input().split()))
d = int(s[0])
mode = s[-1]
if mode == 'week':
	if d < 5 or d == 7:
		print(52)
	else:
		print(53)
elif d <= 29:
	print(12)
elif d == 30:
	print(11)
else:
	print(7)


sent = input().split()
x = int(sent[0])
if sent[-1] == 'week':
	if x in [5, 6]:
		print(53)
	else:
		print(52)
elif x == 31:
	print(7)
elif x == 30:
	print(11)
else:
	print(12)


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


a = input().split()
day = int(a[0])
if a[2] == 'week':
	cnt = 52 + (int(a[0]) == 5) + (int(a[0]) == 6)
elif a[2] == 'month':
	if day <= 29:
		cnt = 12
	elif day == 30:
		cnt = 11
	elif day == 31:
		cnt = 7
print(cnt)


import datetime
start = datetime.datetime(2016, 1, 1, 1, 0, 0)
step = datetime.timedelta(days=1)
a = input().split(' ')
n = int(a[0])
res = 0
if a[2] == 'week':
	while start.year == 2016:
		if start.weekday() == n - 1:
			res += 1
		start += step
else:
	while start.year == 2016:
		if start.day == n:
			res += 1
		start += step
print(res)


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())


a = input().split()
if a[2] == 'month':
	print(12 - (int(a[0]) >= 30) - 4 * (int(a[0]) == 31))
else:
	print(53 if int(a[0]) in (5, 6) else 52)


line = input().split()
n = int(line[0])
s = line[2]
if s == 'week':
	if n == 5 or n == 6:
		print(53)
	else:
		print(52)
if s == 'month':
	ans = [12 for i in range(29)]
	ans.append(11)
	ans.append(7)
	print(ans[n - 1])


(Never, fuck_a, Bitch) = input().split()
Never = int(Never)
if Bitch == 'week':
	print(52 + (Never == 6) + (Never == 5))
elif Bitch == 'month':
	print(12 - (Never == 30) - (Never == 31) * 5)


def solve(case, number):
	if case == 'week':
		if number == 5 or number == 6:
			return 53
		else:
			return 52
	elif number <= 29:
		return 12
	elif number == 30:
		return 11
	else:
		return 7
strInput = input()
strArr = strInput.split(' ')
print(solve(strArr[2], int(strArr[0])))


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


import datetime
(a, b, c) = input().split()
a = int(a)
ans = 0
for i in range(1, 13):
	for s in range(1, 32):
		try:
			x = datetime.datetime(2016, i, s)
			if c == 'week' and x.weekday() == a - 1:
				ans += 1
			if c == 'month' and s == a:
				ans += 1
		except:
			pass
print(ans)


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


def prep():
	a = [0] * 367
	days = [0, 1, 2, 3, 4, 5, 6, 7]
	d = 5
	for k in range(1, len(a)):
		a[k] = days[d]
		d += 1
		if d > 7:
			d = 1
	return a

def solve(s):
	count = 0
	if s.find('week') >= 0:
		d = int(s.split()[0])
		a = prep()
		for k in range(1, len(a)):
			if a[k] == d:
				count += 1
	else:
		d = int(s.split()[0])
		a = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
		for k in range(len(a)):
			if a[k] >= d:
				count += 1
	print(count)

def main():
	s = input()
	solve(s)

def test():
	solve('30 of month')
main()


weeks = [52, 52, 52, 52, 53, 53, 52]
months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
string = input()
if 'of week' in string:
	string = string.replace('of week', '')
	string = int(string)
	print(weeks[string - 1])
else:
	string = string.replace('of month', '')
	string = int(string)
	n = 0
	for x in months:
		if x >= string:
			n += 1
	print(n)


from math import *
a = input().split()
if a[2] == 'week':
	if a[0] == '5' or a[0] == '6':
		print(53)
	else:
		print(52)
if a[2] == 'month':
	if a[0] == '31':
		print(7)
	elif a[0] == '30':
		print(11)
	else:
		print(12)


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


dy = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
a = input().split()
x = int(a[0]) - 1
if a[2] == 'month':
	print(len(list((b for b in dy if b > x))))
else:
	i = (x - 4 + 7) % 7
	ans = 0
	while i < 366:
		ans += 1
		i += 7
	print(ans)


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)


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


n = input()
if n[len(n) - 1] == 'h':
	s = n[0] + n[1]
	s = int(s)
	if s == 31:
		print('7')
	elif s == 30:
		print('11')
	else:
		print('12')
else:
	s = n[0]
	s = int(s)
	if s == 5 or s == 6:
		print('53')
	else:
		print('52')


months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
parts = input().split()
day = int(parts[0])
if parts[2] == 'week':
	num_days = sum(months)
	count = num_days // 7
	remainder = num_days % 7
	span = (day - 5 + 7) % 7 + 1
	if span <= remainder:
		count += 1
else:
	count = 0
	for month in months:
		if day <= month:
			count += 1
print(count)


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


import itertools
import math
s = input().split()
n = int(s[0])
i = s[2] == 'week'
if i:
	print(366 // 7 + (5 <= n <= 6))
elif n <= 29:
	print(12)
elif n == 30:
	print(11)
else:
	print(7)


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


(n, b, c) = input().split()
n = int(n)
if c == 'week':
	if n == 5 or n == 6:
		print(53)
	else:
		print(52)
elif n == 30:
	print(11)
elif n == 31:
	print(7)
else:
	print(12)


(a, b, c) = map(str, input().split())
a = int(a)
if c == 'month':
	if a < 30:
		print(12)
	elif a == 30:
		print(11)
	else:
		print(7)
else:
	arr = [52, 52, 52, 52, 53, 53, 52]
	print(arr[a - 1])


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
elif day == 5 or day == 6:
	result = 53
else:
	result = 52
print(result)


(x, y, z) = input().split()
l = [52, 52, 52, 52, 53, 53, 52]
x = int(x)
if z == 'week':
	print(l[x - 1])
elif x == 31:
	print(7)
elif x == 30:
	print(11)
else:
	print(12)


def solve(s):
	if 'week' in s:
		return 53 if s[0] in ['5', '6'] else 52
	if s.split()[0] == '31':
		return 7
	if s.split()[0] == '30':
		return 11
	return 12
s = input()
print(solve(s))


(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')
elif a == 5 or a == 6:
	print('53')
else:
	print('52')


def sol(a):
	if a[-1] == 'week':
		if a[0] == '5' or a[0] == '6':
			print(53)
		else:
			print(52)
	elif a[0] == '31':
		print(7)
	elif a[0] == '30':
		print(11)
	else:
		print(12)
a = list(map(str, input().split()))
sol(a)


(x, y, s) = input().split()
x = int(x)
cnt = 0
if s == 'month':
	if x == 31:
		cnt = 7
	elif x == 30:
		cnt = 11
	else:
		cnt = 12
elif x == 5 or x == 6:
	cnt = 53
else:
	cnt = 52
print(cnt)


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)


s = input()
n = int(s.split()[0])
m = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if 'month' in s:
	k = 0
	for x in m:
		if x >= n:
			k += 1
	print(k)
else:
	k = 0
	for i in range(366):
		if (4 + i) % 7 == n - 1:
			k += 1
	print(k)


a = list(map(str, input().split()))
a[0] = int(a[0])
if a[2] == 'month':
	if a[0] <= 29:
		print(12)
	elif a[0] == 30:
		print(11)
	else:
		print(7)
elif a[0] >= 5 and a[0] != 7:
	print(53)
else:
	print(52)


s = input().split()
x = int(s[0])
if s[2][0] == 'w':
	k = 0
	if x == 5 or x == 6:
		k = 1
	print(366 // 7 + k)
else:
	k = 0
	if x == 31:
		k = 5
	if x == 30:
		k = 1
	print(12 - k)


s = input()
if s.split()[2] == 'week':
	d = int(s.split()[0])
	days = {1: 52, 2: 52, 3: 52, 4: 52, 5: 53, 6: 53, 7: 52}
	print(days[d])
else:
	d = int(s.split()[0])
	if d <= 29:
		print(12)
	elif d == 30:
		print(11)
	else:
		print(7)


(x, o, s) = input().split()
x = int(x)
if s == 'week':
	if x in [1, 2, 3, 4, 7]:
		print(52)
	else:
		print(53)
elif x == 30:
	print(11)
elif x == 31:
	print(7)
else:
	print(12)


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

def fun(n, m, k):
	pass
from sys import *
import inspect
import re
from math import *
import threading
from collections import *
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 5

def lie():
	return int(input())

def liee():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def deb(p):
	for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
		m = re.search('\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)
		print('%s %d' % (m.group(1), p))

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 dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
main()


s = str(input())
dn = [52, 52, 52, 52, 53, 53, 52]
mo = []
for i in range(29):
	mo.append(12)
mo.append(11)
mo.append(7)
if s.find('week') != -1:
	nw = int(s[0])
	print(dn[nw - 1])
else:
	mw = int(s.split()[0])
	print(mo[mw - 1])


import datetime
(x, of, y) = input().split()
x = int(x)
cnt = 0
d = datetime.date(2016, 1, 1)
while d.year < 2017:
	if y == 'week' and x == d.isoweekday():
		cnt += 1
	if y == 'month' and x == d.day:
		cnt += 1
	d += datetime.timedelta(1)
print(cnt)


s = map(str, input().split())
s = list(s)
x = int(s[0])
if s[2] == 'week':
	if x == 5 or x == 6:
		print('53')
	else:
		print('52')
elif x < 30:
	print('12')
elif x == 30:
	print('11')
else:
	print('7')


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


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)
main()


st = input()
if st[-4:] == 'week':
	if st[0] in '56':
		r = 53
	else:
		r = 52
elif int(st[:2]) <= 29:
	r = 12
elif st[:2] == '31':
	r = 7
else:
	r = 11
print(r)


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


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


import sys
line = input().split()
dia = int(line[0])
if line[2] == 'week':
	if dia == 5 or dia == 6:
		print('53')
	else:
		print('52')
elif dia <= 29:
	print('12')
elif dia == 30:
	print('11')
else:
	print('7')


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)


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)


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


month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
week = [52, 52, 52, 52, 53, 53, 52]
x = list(input().split())
if 'week' in x:
	print(week[int(x[0]) - 1])
else:
	c = 0
	for i in month:
		if int(x[0]) <= i:
			c += 1
	print(c)


(a, a1, a2) = input().split()
b = int(a)
if a2 == 'week':
	if 7 > b > 4:
		print(53)
	else:
		print(52)
elif b == 31:
	print(7)
elif b == 30:
	print(11)
else:
	print(12)


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


(x, _, plan) = input().split()
x = int(x)
if plan == 'week':
	print(53 if x in (5, 6) else 52)
else:
	print(12 if x < 30 else 11 if x == 30 else 7)


import sys
inputs = sys.stdin.readline().split()
x = int(inputs[0])
out = 0
if inputs[2] == 'week':
	w = 5
	for i in range(366):
		if w == x:
			out += 1
		w += 1
		if w == 8:
			w = 1
else:
	if x <= 29:
		out = 12
	if x == 30:
		out = 11
	if x == 31:
		out = 7
print(out)


import itertools, functools, math

def solve():
	(n, of, time) = input().split()
	n = int(n)
	if time == 'month':
		if n <= 29:
			return 12
		if n == 30:
			return 11
		if n == 31:
			return 7
	if time == 'week':
		r = 0
		weekday = 5
		for day in range(366):
			if weekday == n:
				r += 1
			weekday += 1
			if weekday == 8:
				weekday = 1
		return r
print(solve())


l = input()
day = int(l.split()[0])
if 'month' in l:
	if day == 31:
		print(7)
	elif day == 30:
		print(11)
	else:
		print(12)
elif day in [1, 2, 3, 4, 7]:
	print(52)
else:
	print(53)


d = [(5, 31), (1, 29), (2, 31), (5, 30), (7, 31), (3, 30), (5, 31), (1, 31), (4, 30), (6, 31), (2, 30), (4, 31)]
k = [52, 52, 52, 52, 53, 53, 52]
n = input().split()
ans = 0
if n[-1] == 'week':
	print(k[int(n[0]) - 1])
	exit()
else:
	for i in d:
		if i[1] >= int(n[0]):
			ans += 1
print(ans)


n = input().split()
if n[-1] == 'month':
	if n[0] == '31':
		print(7)
	elif n[0] == '30':
		print(11)
	else:
		print(12)
elif n[0] in ['1', '2', '3', '4', '7']:
	print(52)
else:
	print(53)


x = input()
a = x.find('week')
if a != -1:
	if x == '6 of week' or x == '5 of week':
		print(53)
	else:
		print(52)
elif x == '30 of month':
	print(11)
elif x == '31 of month':
	print(7)
else:
	print(12)


import datetime
ans = 0
(x, *s) = input().split()
cur = datetime.date(2016, 1, 1)
while cur.year != 2017:
	if s == ['of', 'week']:
		ans += cur.isoweekday() == int(x)
	else:
		ans += cur.day == int(x)
	cur += datetime.timedelta(1)
print(ans)


(n, temp, tp) = input().split()
n = int(n)
ans = 0
if tp == 'month':
	for x in [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]:
		if x >= n:
			ans += 1
else:
	n -= 1
	cur = 4
	for i in range(366):
		if cur == n:
			ans += 1
		cur += 1
		if cur == 7:
			cur = 0
print(ans)


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)


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


(a, b) = input().split(' of ')
if b == 'month':
	if int(a) in range(1, 30):
		res = 12
	elif int(a) == 30:
		res = 11
	elif int(a) == 31:
		res = 7
elif int(a) in [5, 6]:
	res = 53
else:
	res = 52
print(res)


s = input()
days52 = [1, 2, 3, 4, 7]
s1 = ''
for i in s:
	if i.isdigit() == True:
		s1 += i
if 'week' in s:
	if int(s1) in days52:
		print(52)
	else:
		print(53)
if 'month' in s:
	if int(s1) == 30:
		print(11)
	elif int(s1) == 31:
		print(7)
	else:
		print(12)


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


a = input().split()
(a, i) = (int(a[0]), a[2])
if i == 'week':
	curdays = (a + 7 - 5) % 7
	if 5 <= a <= 6:
		print(53)
	else:
		print(52)
elif a <= 29:
	print(12)
elif a <= 30:
	print(11)
else:
	print(7)


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


M = [31] * 7 + [30] * 4 + [29]
(n, _, s) = input().split()
print(52 + (n in '56') if s > 'n' else sum((i >= int(n) for i in M)))


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


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