Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: $\left. \begin{array}{|r|r|r|r|r|r|} \hline & {2} & {9} & {16} & {23} & {30} \\ \hline & {3} & {10} & {17} & {24} & {31} \\ \hline & {4} & {11} & {18} & {25} & {} \\ \hline & {5} & {12} & {19} & {26} & {} \\ \hline & {6} & {13} & {20} & {27} & {} \\ \hline & {7} & {14} & {21} & {28} & {} \\ \hline 1 & {8} & {15} & {22} & {29} & {} \\ \hline \end{array} \right.$ 

Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap.


-----Input-----

The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday).


-----Output-----

Print single integer: the number of columns the table should have.


-----Examples-----
Input
1 7

Output
6

Input
1 1

Output
5

Input
11 6

Output
5



-----Note-----

The first example corresponds to the January 2017 shown on the picture in the statements.

In the second example 1-st January is Monday, so the whole month fits into 5 columns.

In the third example 1-st November is Saturday and 5 columns is enough.

Difficulty: EASY

Solutions:
(x, y) = map(int, input().split())
z = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
k = (z[x - 1] - (abs(y - 7) + 1)) / 7
j = (z[x - 1] - (abs(y - 7) + 1)) % 7
if j == 0:
	print(int(k + 1))
else:
	print(int(k + 2))


X = list(map(int, input().split()))
if X[0] in [1, 3, 5, 7, 8, 10, 12]:
	print(5 if X[1] <= 5 else 6)
	exit()
if X[0] in [11, 9, 6, 4]:
	print(5 if X[1] <= 6 else 6)
	exit()
print(4 if X[1] == 1 else 5)


l = input().split(' ')
m = int(l[0])
d = int(l[1])
counter = 4
s = 1 - d
while s < 0:
	s += 7
if s > 0:
	counter += 1
a = 28 + s
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	if 31 - a > 0:
		counter += 1
if m == 4 or m == 6 or m == 9 or (m == 11):
	if 30 - a > 0:
		counter += 1
if m == 2:
	if 28 - a > 0:
		counter += 1
print(counter)


(m, d) = list(map(int, input().split()))
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
m -= 1
t = l[m]
first_col = 8 - d
t -= first_col
c = 1
while t > 0:
	t -= 7
	c += 1
print(c)


(month, day) = input().split(' ')
if month == '2':
	if day == '1':
		print('4')
	else:
		print('5')
elif month in ('4', '6', '9', '11'):
	if day == '7':
		print('6')
	else:
		print('5')
elif day in ('6', '7'):
	print('6')
else:
	print('5')


def col(m, d):
	months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	ans = (d - 1 + months[m - 1] - 1) // 7 + 1
	return ans
(mo, day) = map(int, input().split())
print(col(mo, day))


def myf(m, d):
	m = m - 1
	month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	res = 0
	res += int((month[m] + d) / 7)
	if int((month[m] + d) % 7) > 1:
		res = res + 1
	return res
(m, d) = map(int, input().split())
res = myf(m, d)
print(res)


(month, day) = map(int, input().split())
d = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
first_column = 8 - day
rem_days = d[month] - first_column
if rem_days % 7 == 0:
	print(rem_days // 7 + 1)
else:
	print(rem_days // 7 + 2)


import math
(m, d) = map(int, input().split())
if m < 8 and m % 2 == 1:
	c = 31
elif m == 2:
	c = 28
elif m < 8:
	c = 30
elif m >= 8 and m % 2 == 0:
	c = 31
else:
	c = 30
l = 8 - d
c -= l
print(math.ceil(c / 7) + 1)


import sys

def main():
	(m, d) = map(int, sys.stdin.readline().split())
	months = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
	m = months[m]
	if d == 1:
		if m % 7 == 0:
			print(m // 7)
		else:
			print(m // 7 + 1)
	else:
		m -= 7 - d + 1
		if m % 7 == 0:
			print(m // 7 + 1)
		else:
			print(m // 7 + 2)
main()


(m, d) = map(int, input().split())
if m == 2:
	l = 28
elif m <= 7:
	if m % 2 == 0:
		l = 30
	else:
		l = 31
elif m % 2 == 0:
	l = 31
else:
	l = 30
c = 1
l = l - (8 - d)
c += l // 7 + (0 if l % 7 == 0 else 1)
print(c)


import math
(m, d) = map(int, input().split(' '))
days = 0
sol = 1
if m == 2:
	days = 28
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	days = 31
if m == 4 or m == 6 or m == 9 or (m == 11):
	days = 30
print(math.ceil((days + d - 1) / 7))


year = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
days = year[m - 1]
days -= 7 - d + 1
print(days // 7 + int(bool(days % 7)) + 1)


(m, d) = map(int, input().split())
q = 0
if m <= 7:
	q = 30 + m % 2
else:
	q = 31 - m % 2
if m == 2:
	q = 28
p = q - 28
if p > 8 - d:
	print(6)
elif p == 0 and d == 1:
	print(4)
else:
	print(5)


(n, m) = map(int, input().strip().split()[:2])
m31 = [1, 3, 5, 7, 8, 10, 12]
m30 = [4, 6, 9, 11]
m28 = [2]
if n in m31:
	k = m - 1 + 31
	if k % 7 == 0:
		print(k // 7)
	else:
		print(k // 7 + 1)
elif n in m30:
	k = m - 1 + 30
	if k % 7 == 0:
		print(k // 7)
	else:
		print(k // 7 + 1)
else:
	k = m - 1 + 28
	if k % 7 == 0:
		print(k // 7)
	else:
		print(k // 7 + 1)


(m, d) = map(int, input().split())
mes = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print((mes[m - 1] + d + 5) // 7)


list = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
n = list[m]
n = n - (8 - d)
a = int(n / 7)
if n % 7 != 0:
	a += 1
print(1 + a)


import itertools

def main():
	data = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	(n, m) = [int(v) for v in input().split()]
	days = data[n - 1] - (7 - m + 1)
	print(days // 7 + 1 if days % 7 == 0 else days // 7 + 2)
main()


days_in_month = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
(m, d) = tuple(map(int, input().split()))
days = days_in_month[m]
col = 1
days -= 8 - d
col += days // 7
if days % 7 > 0:
	col += 1
print(col)


(m, d) = map(int, input().split())
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if d != 1:
	a = 7 - d + 28 + 1
	if l[m - 1] > a:
		print('6')
	else:
		print('5')
elif l[m - 1] > 28:
	print('5')
else:
	print('4')


(m, d) = map(int, input().split(' '))
ms = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
m_d = ms[m - 1]
f_s = 8 - d
s_s = (m_d - f_s) // 7
p_s = m_d - f_s - (m_d - f_s) // 7 * 7
l_s = 1
if p_s == 0:
	l_s = 0
print(1 + s_s + l_s)


M = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = list(map(int, input().split()))
n = M[m]
n += d - 1
if n % 7 == 0:
	n /= 7
	print(int(n))
else:
	n /= 7
	print(int(n) + 1)


import math
(a, b) = map(int, input().split())
k = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print(math.ceil((k[a - 1] + b - 1) / 7))


(m, d) = list(map(int, input().split()))
a31 = [1, 3, 5, 7, 8, 10, 12]
c = 30
if m in a31:
	c = 31
elif m == 2:
	c = 28
c -= 8 - d
print(1 + (c + 6) // 7)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
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 I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(a, b) = LI()
	l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	x = l[a - 1]
	if a == 2:
		if b == 1:
			return 4
		return 5
	elif x == 30:
		if b == 7:
			return 6
		return 5
	else:
		if b >= 6:
			return 6
		return 5
print(main())


def get_total_days(month):
	if month == 2:
		return 28
	if month == 7 or month == 8:
		return 31
	if month % 2 == 0:
		if month <= 7:
			return 30
		return 31
	else:
		if month <= 7:
			return 31
		return 30

def solve(month, weekday):
	days = get_total_days(month)
	weeks = days // 7
	remainder_days = days % 7
	if weekday == 1 and remainder_days == 0:
		return weeks
	additional_weeks = 2 if weekday + remainder_days > 8 else 1
	return weeks + additional_weeks

def main():
	(month, weekday) = input().split()
	answer = solve(int(month), int(weekday))
	print(answer)
	return answer
main()


(m, d) = map(int, input().split())
if m == 1:
	m = d - 1 + 31
elif m == 2:
	m = d - 1 + 28
elif m == 3:
	m = d - 1 + 31
elif m == 4:
	m = d - 1 + 30
elif m == 5:
	m = d - 1 + 31
elif m == 6:
	m = d - 1 + 30
elif m == 7:
	m = d - 1 + 31
elif m == 8:
	m = d - 1 + 31
elif m == 9:
	m = d - 1 + 30
elif m == 10:
	m = d - 1 + 31
elif m == 11:
	m = d - 1 + 30
else:
	m = d - 1 + 31
ans = int(m / 7)
if m % 7 != 0:
	ans = ans + 1
print(ans)


(m, d) = map(int, input().split())
nd = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m]
nc = 0
nd = nd - (8 - d)
nc = nc + 1
while nd > 0:
	nd = nd - 7
	nc = nc + 1
print(nc)


(m, d) = map(int, input().split())
l = [1, 3, 5, 7, 8, 10, 12]
if m in l:
	print((d - 1 + 31 - 1) // 7 + 1)
elif m == 2:
	print((d - 1 + 28 - 1) // 7 + 1)
else:
	print((d - 1 + 30 - 1) // 7 + 1)


import math

def main():
	months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	(m, d) = (int(x) for x in input().split())
	print(1 + math.ceil((months[m - 1] - (8 - d)) / 7))
main()


(m, d) = list(map(int, input().split()))
l = [None] + [31, 28] + [31, 30] * 2 + [31, 31] + [30, 31] * 2
print((l[m] + d + 5) // 7)


def columnsNumber(m, d):
	monthdays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	m = monthdays[m - 1] + d - 1
	d = m / 7
	if m % 7 == 0:
		return d
	else:
		return d + 1
(m, d) = map(int, input().split())
x = int(columnsNumber(m, d))
print(x)


(m, d) = map(int, input().split())
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	ans = (d - 1 + 30) // 7 + 1
elif m == 2:
	ans = (d - 1 + 27) // 7 + 1
else:
	ans = (d - 1 + 29) // 7 + 1
print(ans)


from math import ceil
(m, d) = [int(item) for item in input().split()]
ans = 4
if m == 2:
	if d != 1:
		ans += 1
elif m in [1, 3, 5, 7, 8, 10, 12]:
	if d >= 6:
		ans += 2
	else:
		ans += 1
elif d == 7:
	ans += 2
else:
	ans += 1
print(ans)


(x, y) = map(int, input().split())
if x == 2:
	print(4 if y == 1 else 5)
elif x in [4, 6, 9, 11]:
	print(6 if y == 7 else 5)
else:
	print(6 if y >= 6 else 5)


from math import ceil as c
(m, d) = map(int, input().split())
months = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print(c((d - 1 + months[m]) / 7))


n = input()
n = n.split()
b = 0
if int(n[0]) == 1 or int(n[0]) == 3 or int(n[0]) == 5 or (int(n[0]) == 7) or (int(n[0]) == 8) or (int(n[0]) == 10) or (int(n[0]) == 12):
	a = 31
	a = a - (8 - int(n[1]))
	if a % 7 == 0:
		b = 1 + a // 7
		print(b)
	else:
		b = 1 + (a // 7 + 1)
		print(b)
elif int(n[0]) == 4 or int(n[0]) == 6 or int(n[0]) == 9 or (int(n[0]) == 11):
	a = 30
	a = a - (8 - int(n[1]))
	if a % 7 == 0:
		b = 1 + a // 7
		print(b)
	else:
		b = 1 + (a // 7 + 1)
		print(b)
else:
	a = 28
	a = a - (8 - int(n[1]))
	if a % 7 == 0:
		b = 1 + a // 7
		print(b)
	else:
		b = 1 + (a // 7 + 1)
		print(b)


(a, b) = map(int, input().split())
c = [1, 3, 5, 7, 8, 10, 12]
d = [4, 6, 9, 11]
if a in c and (b == 6 or b == 7) or (a in d and b == 7):
	print(6)
elif a == 2 and b == 1:
	print(4)
else:
	print(5)


import sys
import math
day_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
ans = 1 + math.ceil((day_month[m - 1] - (7 - d + 1)) / 7)
print(ans)
print('test', file=sys.stderr)


from math import ceil as c
l = [1, 3, 5, 7, 8, 10, 12]
(m, d) = map(int, input().split())
if m in l:
	print(c((31 - (8 - d)) / 7) + 1)
elif m == 2:
	print(c((28 - (8 - d)) / 7) + 1)
else:
	print(c((30 - (8 - d)) / 7) + 1)


from math import ceil

def solve(m, d):
	x = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	return ceil((x[m - 1] + d - 1) / 7)

def main():
	(m, d) = list(map(int, input().split()))
	print(solve(m, d))
main()


def ceild(a, b):
	return -(-a // b)
n = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
print(ceild(n[m - 1] + d - 1, 7))


(m, start) = list(map(int, input().split()))
days = 0
if m in [1, 3, 5, 7, 8, 10, 12]:
	days = 31
elif m == 2:
	days = 28
else:
	days = 30
result = 1
days -= 7 - start + 1
result += days // 7
if days % 7 != 0:
	result += 1
print(result)


(n, d) = map(int, input().split())
li = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print((li[n] + d + 5) // 7)


(m, d) = map(int, input().split())
l_m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
t_d = l_m[m - 1]
print((d + t_d - 1) // 7 + (1 if (d + t_d - 1) % 7 != 0 else 0))


import math
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()

def s(a):
	print('+'.join(list(map(str, a))))
(m, d) = M()
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	if d < 6:
		print(5)
	else:
		print(6)
elif m == 2:
	if d == 1:
		print(4)
	else:
		print(5)
elif d == 7:
	print(6)
else:
	print(5)


(m, d) = map(int, input().split())
if m in (1, 3, 5, 7, 8, 10, 12):
	if d > 5:
		print(6)
	else:
		print(5)
elif m == 2:
	if d == 1:
		print(4)
	else:
		print(5)
elif d == 7:
	print(6)
else:
	print(5)


(x, y) = map(int, input().split())
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print((days[x - 1] + (y - 1) + 6) // 7)


a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
k = a[m - 1]
k += d - 1
if k % 7 == 0:
	print(k // 7)
else:
	print(k // 7 + 1)


(a, b) = list(map(int, input().split()))
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print((b + l[a - 1] - 2) // 7 + 1)


our = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
m -= 1
days = our[m]
res = 1
days = days + d - 8
print((days - 1) // 7 + 2)


(m, d) = map(int, input().split())
thione = [1, 3, 5, 7, 8, 10, 12]
thirty = [4, 6, 9, 11]
tweeig = [2]
if m in thione:
	days = 31
elif m in thirty:
	days = 30
else:
	days = 28
if days == 28:
	if d == 1:
		print(4)
	else:
		print(5)
elif days == 30:
	if d == 7:
		print(6)
	else:
		print(5)
elif d >= 6:
	print(6)
else:
	print(5)


import math
(n, k) = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [2]
if n in a:
	print(1 + math.ceil((23 + k) / 7))
elif n == 2:
	print(1 + math.ceil((20 + k) / 7))
else:
	print(1 + math.ceil((22 + k) / 7))


(n, m) = map(int, input().split())
p = set([1, 3, 5, 7, 8, 10, 12])
if n == 2:
	l = 28
elif n in p:
	l = 31
else:
	l = 30
print((l - (8 - m) - 1) // 7 + 2)


(m, d) = map(int, input().split())
if d == 1:
	print(5 - (m == 2))
elif d < 6:
	print(5)
elif d == 6:
	print(6 - (m in (2, 4, 6, 9, 11)))
else:
	print(6 - (m == 2))


(a, b) = [int(i) for i in input().split()]
if a == 1 or a == 3 or a == 5 or (a == 7) or (a == 8) or (a == 10) or (a == 12):
	if b <= 5:
		print(5)
	else:
		print(6)
elif a == 4 or a == 6 or a == 9 or (a == 11):
	if b <= 6:
		print(5)
	else:
		print(6)
elif b > 1:
	print(5)
else:
	print(4)


def codeforces(m, d):
	if m == 2:
		days = 28
	elif m in [1, 3, 5, 7, 8, 10, 12]:
		days = 31
	else:
		days = 30
	days -= 8 - d
	weeks = 1 + days // 7
	if days % 7:
		weeks += 1
	return weeks
(m, d) = map(int, input().split())
print(codeforces(m, d))


(m, first_day) = list(map(int, input().split()))
year = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days_num = year[m - 1]
left = days_num - (7 - first_day + 1)
if left % 7 == 0:
	print(1 + left // 7)
else:
	print(2 + left // 7)


(m, d) = list(map(int, input().split()))
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	x = 31
elif m == 4 or m == 6 or m == 9 or (m == 11):
	x = 30
else:
	x = 28
x -= 8 - d
ans = 1
while x > 0:
	x -= 7
	ans += 1
print(ans)


from sys import stdin
from math import ceil
(m, d) = map(int, stdin.readline().split())
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print(ceil((days[m - 1] + (d - 1)) / 7))


(m, d) = map(int, input().split())
days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print((days[m] + d - 1 + 6) // 7)


a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
q = a[m - 1]
s = 0
q -= 7 - d + 1
s += 1
s += q // 7
if q % 7 != 0:
	s += 1
print(s)


import math
(m, d) = map(int, input().split())
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print(math.ceil((a[m - 1] + d - 1) / 7))


(m, d) = map(int, input().split())
if m == 2:
	if d > 1:
		print(5)
	else:
		print(4)
elif d > 6:
	print(6)
elif d < 6:
	print(5)
elif d == 6:
	l = [1, 2, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]
	if l[m - 1] == 0:
		print(5)
	else:
		print(6)


import math, sys

def main():
	(n, d) = map(int, input().split())
	months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	k = months[n - 1] - (8 - d)
	ans = 1 + k // 7 + int(k % 7 > 0)
	print(ans)
main()


(m, d) = map(int, input().split())
days = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
ans = 1
dd = 9 - d
while dd <= days[m]:
	ans = ans + 1
	dd = dd + 7
print(ans)


dayCount = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
d = d - 1
Ans = 1
for i in range(dayCount[m]):
	if d == 7:
		d = 0
		Ans = Ans + 1
	d = d + 1
print(Ans)


(x, y) = map(int, input().split())
d = {1, 3, 5, 7, 8, 10, 12}
f = {2}
e = {4, 6, 9, 11}
if x in d:
	if y == 6 or y == 7:
		print(6)
	else:
		print(5)
elif x in e:
	if y == 7:
		print(6)
	else:
		print(5)
elif y == 1:
	print(4)
else:
	print(5)


month_day = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(n, m) = map(int, input().split(' '))
a = (m - 1 + month_day[n]) // 7
b = (m - 1 + month_day[n]) % 7
if b == 0:
	print(a)
else:
	print(a + 1)


dc = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
print((dc[m] + d + 5) // 7)


def nod(m):
	list1 = [1, 3, 5, 7, 8, 10, 12]
	if m in list1:
		return 31
	else:
		return 30

def solve(m, d):
	if m == 2:
		if d == 1:
			return 4
		return 5
	elif nod(m) == 30:
		if d == 7:
			return 6
		else:
			return 5
	elif d == 6 or d == 7:
		return 6
	else:
		return 5
(m, d) = input().strip().split(' ')
(m, d) = (int(m), int(d))
print(solve(m, d))


mm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
print((mm[m - 1] + d - 2) // 7 + 1)


import math
(m, d) = map(int, input().split())
d = 8 - d
count = 0
if m == 2:
	c = 28
elif m == 4 or m == 6 or m == 9 or (m == 11):
	c = 30
else:
	c = 31
c -= d
count += 1
count += math.ceil(c / 7)
print(count)


(a, b) = map(int, input().split())
if a in range(1, 8, 2) or a in range(8, 13, 2):
	if b == 6 or b == 7:
		print(6)
	else:
		print(5)
elif a == 2:
	if b == 1:
		print(4)
	else:
		print(5)
elif b == 7:
	print(6)
else:
	print(5)


days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
[m, d] = list(map(int, input().split()))
x = days[m - 1]
x += d - 1
res = (x + 6) // 7
print(res)


(m, d) = map(int, input().split())
m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1]
days_left = m - (8 - d)
print(days_left // 7 + (days_left % 7 != 0) + 1)


import math
days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
ans = math.ceil((days[m] + d - 1) / 7)
print(ans)


alph = 'abcdefghijklmnopqrstuvwxyz'
(m, d) = map(int, input().split())
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
m = a[m - 1]
E = 1
m -= 8 - d
E += m // 7 + int(m % 7 != 0)
print(E)


import math
mon_day = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(mon, day) = map(int, input().split())
tot = day - 1 + mon_day[mon]
print(math.ceil(tot / 7))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, random
(m, d) = map(int, input().split())
L = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = L[m - 1]
days0 = abs(d - 7) + 1
col = 1
remDays = days - days0
col += math.ceil(remDays / 7)
print(col)


def main():
	(m, d) = map(int, input().split())
	a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	num = a[m - 1]
	ans = 1
	num -= 8 - d
	ans += (num + 7 - 1) // 7
	print(ans)
main()


from sys import stdin
import math
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(M, D) = map(int, stdin.readline().split())
M -= 1
D -= 1
print(math.ceil((days_in_month[M] + D) / 7))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

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

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

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	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) % MOD

def comb(n, x):
	(a, b) = (1, 1)
	for i in range(1, x + 1):
		a *= n + 1 - i
		b *= i
	return a // b % MOD

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 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 and n > 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):
	if y == 0:
		return 1
	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)]
	(prime[0], prime[1]) = (False, False)
	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

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.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
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
small = 'abcdefghijklmnopqrstuvwxyz'
large = small.upper()
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	(m, d) = read()
	month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	s = 6
	for i in range(m):
		s += month[i]
	startday = s % 7
	print((d + month[m] + 5) // 7)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = 1
for i in range(t):
	solve()


(month, day) = list(map(int, input().split()))
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
fs = 7 - day + 1
counter = 1
while fs + 7 <= months[month - 1]:
	counter += 1
	fs += 7
if fs != months[month - 1]:
	counter += 1
print(counter)


def read_input():
	line = input().strip().split()
	m = int(line[0])
	week = int(line[1])
	days31 = {1, 3, 5, 7, 8, 10, 12}
	if m == 2:
		days = 28
	elif m in days31:
		days = 31
	else:
		days = 30
	z = days + week - 1
	return z // 7 if z % 7 == 0 else z // 7 + 1
print(read_input())


(m, d) = map(int, input().split())
d -= 1
ans = 1
ds = 31
if m in [4, 6, 9, 11]:
	ds = 30
elif m == 2:
	ds = 28
for j in range(2, ds + 1):
	d += 1
	if d % 7 == 0:
		ans += 1
print(ans)


mon = [3, 0, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3]
(m, d) = map(int, input().split())
print(4 if d == 1 and m == 2 else 6 if mon[m - 1] > 8 - d else 5)


(m, d) = list(map(int, input().split()))
if m == 4 or m == 6 or m == 9 or (m == 11):
	n = 30
elif m == 2:
	n = 28
else:
	n = 31
if m == 2 and d == 1:
	print(4)
elif n == 30 and d == 7:
	print(6)
elif n == 31 and (d == 6 or d == 7):
	print(6)
else:
	print(5)


(m, d) = [int(i) for i in input().split()]
days_in_month = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
count_day = days_in_month.get(m)
count_day -= 8 - d
weeks = count_day // 7
f_week = count_day % 7
weeks += 1
if f_week > 0:
	weeks += 1
print(weeks)


import math
monthsLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
i = input().split(' ')
a = [int(x) for x in i]
(month, weekday) = (a[0], a[1])
print(math.ceil((monthsLength[month - 1] + weekday - 1) / 7))


(m, d) = map(int, input().split())
months = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
columns_num = 0
if months[m] % 7 == 0:
	if d != 1:
		columns_num = months[m] // 7 + 1
	else:
		columns_num = months[m] // 7
elif months[m] % 7 != 0:
	if months[m] == 31 and (d == 7 or d == 6):
		columns_num = months[m] // 7 + 2
	elif months[m] == 30 and d == 7:
		columns_num = months[m] // 7 + 2
	else:
		columns_num = months[m] // 7 + 1
print(columns_num)


from math import ceil
(m, d) = map(int, input().split())
D = 28 if m == 2 else 30 if m in (4, 6, 9, 11) else 31
print(1 + ceil((D - (8 - d)) / 7))


import math
(m, d) = map(int, input().split())
if m == 2:
	print(math.ceil((20 + d) / 7) + 1)
elif m >= 8:
	if m % 2 == 0:
		print(math.ceil((23 + d) / 7) + 1)
	else:
		print(math.ceil((22 + d) / 7) + 1)
elif m % 2 == 0:
	print(math.ceil((22 + d) / 7) + 1)
else:
	print(math.ceil((23 + d) / 7) + 1)


(m, d) = input().split()
(m, d) = [int(m), int(d)]
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	ndays = 31
elif m == 2:
	ndays = 28
else:
	ndays = 30
print((d - 1 + ndays - 1) // 7 + 1)


refer = (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
(m, d) = map(int, input().split())
print((refer[m] + d - 2) // 7 + 1)


(m, d) = map(int, input().split())
if m == 2:
	nd = 28
elif m == 4 or m == 6 or m == 9 or (m == 11):
	nd = 30
else:
	nd = 31
print((d - 1 + nd - 1) // 7 + 1)


def main():
	dim = list(map(int, input().split()))
	if dim[0] == 2:
		if dim[1] > 1:
			print(5, end='')
		else:
			print(4, end='')
		return
	elif dim[0] in [1, 3, 5, 7, 8, 10, 12]:
		if dim[1] <= 5:
			print(5, end='')
		else:
			print(6, end='')
		return
	else:
		if dim[1] <= 6:
			print(5, end='')
		else:
			print(6, end='')
		return
main()


(m, d) = map(int, input().split())
if m == 2:
	k = 28
elif m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	k = 31
else:
	k = 30
broj_tjedana = 1
nedjelja = 7 - d + 1
while nedjelja < k:
	broj_tjedana += 1
	nedjelja += 7
print(broj_tjedana)


(m, d) = input().split(' ')
(m, d) = (int(m), int(d))
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(weeks, rest) = divmod(days[m - 1] - (8 - d), 7)
print(weeks + (1 if rest != 0 else 0) + 1)


(month, day) = map(int, input().split())
if month == 2:
	month_length = 28
elif month <= 7:
	month_length = 30 if month % 2 == 0 else 31
else:
	month_length = 31 if month % 2 == 0 else 30
month_length -= 7 - day + 1
(full_weeks, remains) = divmod(month_length, 7)
print(full_weeks + 1 + (remains > 0))


from math import ceil
(m, d) = map(int, input().split())
days = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
a = days[m] - (8 - d)
b = ceil(a / 7)
print(b + 1)


(a, b) = map(int, input().split())
cnt = 1
if a <= 7:
	if a % 2 == 0 and a != 2:
		c = 8 - b
		while c < 30:
			c += 7
			cnt += 1
	elif a == 2:
		c = 8 - b
		while c < 28:
			c += 7
			cnt += 1
	else:
		c = 8 - b
		while c < 31:
			c += 7
			cnt += 1
elif a % 2 != 0:
	c = 8 - b
	while c < 30:
		c += 7
		cnt += 1
else:
	c = 8 - b
	while c < 31:
		c += 7
		cnt += 1
print(cnt)


(m, d) = list(map(int, input().split()))
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
import math
day = days[m - 1]
print(math.ceil((day + d - 1) / 7))


(m, d) = map(int, input().split())
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print((a[m - 1] + (d - 1) + 6) // 7)


import math
(m, d) = (int(x) for x in input().split())
mday = 28 if m == 2 else 31 if m <= 7 and m & 1 or (m > 7 and (not m & 1)) else 30
print(int(math.ceil((mday - (7 - d + 1)) / 7) + 1))


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))
(m, d) = IL()
C = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
nd = d - 1 + C[m - 1]
print(nd // 7 + bool(nd % 7))


md = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
fsl = 7 - d + 1
md[m - 1] -= fsl
print(1 - -md[m - 1] // 7)


a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(n, k) = map(int, input().split())
print(1 + (a[n - 1] - (8 - k) + 6) // 7)


from math import *
li = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
print(ceil((li[m - 1] - 8 + d) / 7) + 1)


(m, d) = map(int, input().split())
nd = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1]
print(1 + (nd - (8 - d) - 1) // 7 + 1)


import sys
(a, b) = input().split()
a = int(a)
b = int(b)
lk = 0
lk = int(lk)
if a == 2:
	if b != 1:
		print('5')
		sys.exit()
	else:
		print('4')
		sys.exit()
if a == 1 or a == 3 or a == 5 or (a == 7) or (a == 8) or (a == 10) or (a == 12):
	if b == 6 or b == 7:
		print('6')
		sys.exit()
	else:
		print('5')
		sys.exit()
elif b == 7:
	print('6')
else:
	print('5')


(m, d) = input().split()
m = int(m)
d = int(d)
L = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
n = L[m - 1]
if d == 7:
	c = 1
if d == 6:
	c = 2
if d == 5:
	c = 3
if d == 4:
	c = 4
if d == 3:
	c = 5
if d == 2:
	c = 6
if d == 1:
	c = 7
n = n - c
res = 1
if n > 0:
	n = n - 7
	res = res + 1
if n > 0:
	n = n - 7
	res = res + 1
if n > 0:
	n = n - 7
	res = res + 1
if n > 0:
	n = n - 7
	res = res + 1
if n > 0:
	n = n - 7
	res = res + 1
if n > 0:
	n = n - 7
	res = res + 1
if n > 0:
	n = n - 7
	res = res + 1
print(res)


(m, d) = map(int, input().split())
if m in [1, 3, 5, 7, 8, 10, 12]:
	print(6 if d in [6, 7] else 5)
elif m in [4, 6, 9, 11]:
	print(6 if d is 7 else 5)
else:
	print(4 if d is 1 else 5)


from math import ceil
(m, dd) = map(int, input().split())
d = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
md = d[m] + dd - 1
print(int(ceil(md / 7)))


ch = input()
l = []
l = ch.split(' ')
m = int(l[0])
d = int(l[1])
if m in [1, 3, 5, 7, 8, 10, 12]:
	if d in [1, 2, 3, 4, 5]:
		print(5)
	else:
		print(6)
elif m in [4, 6, 9, 11]:
	if d in [1, 2, 3, 4, 5, 6]:
		print(5)
	else:
		print(6)
elif m == 2:
	if d == 1:
		print(4)
	else:
		print(5)


(a, b) = map(int, input().split())
v = [1, 3, 5, 7, 8, 10, 12]
z = [4, 6, 9, 11]
if a in v:
	if b < 6:
		print(5)
	else:
		print(6)
elif a in z:
	if b < 7:
		print(5)
	else:
		print(6)
elif b == 1:
	print(4)
else:
	print(5)


import sys
import math
import bisect
import itertools

def month_days(m):
	if m == 2:
		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():
	(m, d) = map(int, input().split())
	ans = 1
	for i in range(month_days(m)):
		if i:
			d = d + 1
			if d == 8:
				d = 1
				ans += 1
	print(ans)
main()


import calendar
import math
val = list(map(int, input().split()))
n = calendar.mdays[val[0]]
n = n - (7 - val[1] + 1)
w = n / 7
r = n % 7
if r == 0:
	print(int(w + 1))
else:
	print(int(math.floor(w) + 2))


from calendar import monthrange
(n, k) = map(int, input().strip().split())
l1 = [0, 1, 2, 3, 4, 5, 6, 7]
l2 = 7 - l1[k] + 1
NOD = max(monthrange(2017, n))
A = []
if 7 - l1[k] == 0:
	A.append(1)
else:
	A.append(7 - l1[k] + 1)
for i in range(A[0] + 7, NOD + 1, 7):
	if i <= NOD:
		A.append(i)
	if NOD - i < 7 and NOD - i + i not in A:
		A.append(NOD - i + i)
print(len(A))


(a, b) = input().split()
(a, b) = (int(a), int(b))
if a == 1 or a == 3 or a == 5 or (a == 7) or (a == 8) or (a == 10) or (a == 12):
	print((30 + b - 1) // 7 + 1)
elif a == 2:
	print((27 + b - 1) // 7 + 1)
elif a == 4 or a == 6 or a == 11 or (a == 9):
	print((29 + b - 1) // 7 + 1)


def bla():
	monthlengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	(m, n) = tuple(map(int, input().split()))
	if monthlengths[m] == 31:
		if n < 6:
			return 5
		else:
			return 6
	elif monthlengths[m] == 30:
		if n < 7:
			return 5
		else:
			return 6
	elif n == 1:
		return 4
	else:
		return 5
print(bla())


import math
(m, d) = list(map(int, input().split()))
x = 7 - (d - 1)
if m == 2:
	y = 28 - x
elif m == 4 or m == 6 or m == 9 or (m == 11):
	y = 30 - x
else:
	y = 31 - x
s = 1 + y / 7
s = math.ceil(s)
print(s)


months = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(month, weekday) = map(int, input().split())
print((months[month] + weekday - 1 + 6) // 7)


(q, w) = list(map(int, input().split()))
a = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ans = 1
t = a[q] - (8 - w)
while t > 0:
	ans += 1
	t -= 7
print(ans)


(m, d) = list(map(int, input().split()))
d31 = [1, 3, 5, 7, 8, 10, 12]
d30 = [4, 6, 9, 11]
if m in d31:
	if d == 6 or d == 7:
		print(6)
	else:
		print(5)
elif m in d30:
	if d == 7:
		print(6)
	else:
		print(5)
elif d == 1:
	print(4)
else:
	print(5)


days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(month, day) = input().split()
month = int(month)
day = int(day)
columns = days[month - 1] - (7 - day + 1)
result = 0
if columns % 7 != 0:
	result += 1
result += columns // 7 + 1
print(result)


import sys
arr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(a, b) = list(map(int, input().split()))
a -= 1
b -= 1
ctr = 1
for i in range(arr[a] - 1):
	b += 1
	if b == 7:
		b = 0
		ctr += 1
print(ctr)


(m, d) = map(int, input().split())
c = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
t = c[m - 1]
num = 1
for i in range(1, t):
	d += 1
	if d == 8:
		d = 1
		num += 1
print(num)


(x, y) = [int(a) for a in input().split()]
if x <= 7:
	if x % 2 == 0:
		if x != 2:
			if y == 7:
				d = 6
			else:
				d = 5
		elif y == 1:
			d = 4
		else:
			d = 5
	elif y >= 6:
		d = 6
	else:
		d = 5
elif x % 2 == 0:
	if y >= 6:
		d = 6
	else:
		d = 5
elif y == 7:
	d = 6
else:
	d = 5
print(d)


(m, d) = map(int, input().split())
if m < 8:
	if m % 2 != 0:
		if d < 6:
			print('5')
		else:
			print('6')
	elif m == 2:
		if d == 1:
			print('4')
		else:
			print('5')
	elif d < 7:
		print('5')
	else:
		print('6')
elif m % 2 != 0:
	if d < 7:
		print('5')
	else:
		print('6')
elif d < 6:
	print('5')
else:
	print('6')


s = input().split()
m = int(s[0])
d = int(s[1])
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
r = a[m - 1] + (d - 1)
ans = r // 7
if r % 7:
	ans += 1
print(str(ans))


(m, d) = map(int, input().split())
kalendar = [[0 for i in range(7)] for j in range(6)]
D = 1
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	for i in range(6):
		for j in range(7):
			if d == 0:
				kalendar[i][j] = D
				D += 1
			else:
				d -= 1
			if D == 31:
				print(i + 1)
				exit()
elif (m == 4 or m == 6) or (m == 9 or m == 11):
	for i in range(6):
		for j in range(7):
			if d == 0:
				kalendar[i][j] = D
				D += 1
			else:
				d -= 1
			if D == 30:
				print(i + 1)
				exit()
else:
	for i in range(6):
		for j in range(7):
			if d == 0:
				kalendar[i][j] = D
				D += 1
			else:
				d -= 1
			if D == 28:
				print(i + 1)
				exit()


(m, d) = map(int, input().split())
m -= 1
d -= 1
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
cnt = 1
for i in range(a[m]):
	if d == 0 and i > 0:
		cnt += 1
	d = (d + 1) % 7
print(cnt)


def main():
	QWE = 'river'
	INF = 10 ** 18 + 9
	EPS = 10 ** (-10)
	import sys, math, re
	(m, d) = map(int, input().split(' ', 1))
	a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	ans = (a[m - 1] + d + 5) // 7
	print(ans)
main()


from calendar import monthrange

def read(type=int):
	return type(input())

def read_arr(type=int):
	return [type(token) for token in input().split()]

def days(m):
	if m == 2:
		return 28
	if m in {1, 3, 5, 7, 8, 10, 12}:
		return 31
	return 30

def run():
	(m, d) = map(int, input().split())
	d -= 1
	(w, n) = monthrange(2017, m)
	ans = 1
	arr = [0 for i in range(7)]
	while n > 0:
		arr[d] = ans
		d += 1
		if d % 7 == 0:
			ans += 1
			d %= 7
		n -= 1
	print(max(arr))

def run2():
	(m, d) = read_arr()
	(w, n) = monthrange(2017, m)
	ans = 1
	i = d % 7
	for k in range(n):
		i = (i + 1) % 7
		if i % 7 == 1:
			ans += 1
	print(ans)
run()


(n, m) = input().split()
(n, m) = (int(n), int(m))
if n == 1:
	if m <= 5:
		print(5)
	else:
		print(6)
if n == 2:
	if m == 1:
		print(4)
	else:
		print(5)
if n == 3:
	if m <= 5:
		print(5)
	else:
		print(6)
if n == 4:
	if m <= 6:
		print(5)
	else:
		print(6)
if n == 5:
	if m <= 5:
		print(5)
	else:
		print(6)
if n == 6:
	if m <= 6:
		print(5)
	else:
		print(6)
if n == 7:
	if m <= 5:
		print(5)
	else:
		print(6)
if n == 8:
	if m <= 5:
		print(5)
	else:
		print(6)
if n == 9:
	if m <= 6:
		print(5)
	else:
		print(6)
if n == 10:
	if m <= 5:
		print(5)
	else:
		print(6)
if n == 11:
	if m <= 6:
		print(5)
	else:
		print(6)
if n == 12:
	if m <= 5:
		print(5)
	else:
		print(6)


(m, d) = input().split()
m = int(m)
d = int(d)
list = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
x = d - 1 + list[m]
if x % 7 != 0:
	print(x // 7 + 1)
else:
	print(x // 7)


(m, d) = map(int, input().split())
c = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
num = d - 1 + c[m]
col = num // 7
if num % 7 != 0:
	col += 1
print(col)


(m, d) = map(int, input().split())
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = month[m - 1]
answer = 1
days -= 7 - d + 1
if days % 7 == 0:
	answer += days // 7
else:
	answer += days // 7 + 1
print(answer)


import math
from fractions import Fraction as frac

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

def lcm(a, b):
	return a * b // gcd(a, b)

def solve(case_no):
	(m, d) = map(int, input().split())
	td = 0
	if m == 2:
		td = 28
	elif m == 4 or m == 6 or m == 9 or (m == 11):
		td = 30
	else:
		td = 31
	print(math.ceil((td - 8 + d) / 7) + 1)
t = 1
for i in range(1, t + 1):
	solve(i)


import math
mo = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
(m, d) = map(int, input().split())
k = math.ceil((d - 1 + mo[m]) / 7)
print(k)


import sys
(m, d) = input().split()
m = int(m)
d = int(d)
t = 0
x = 0
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	x = 31 - (8 - d)
	if x % 7 > 0:
		t = x // 7 + 2
	else:
		t = x // 7 + 1
	print(t)
elif m == 2:
	x = 28 - (8 - d)
	if x % 7 > 0:
		t = x // 7 + 2
	else:
		t = x // 7 + 1
	print(t)
else:
	x = 30 - (8 - d)
	if x % 7 > 0:
		t = x // 7 + 2
	else:
		t = x // 7 + 1
	print(t)


d = [-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(n, k) = map(int, input().split())
print((d[n] - (7 - k + 1) + 6) // 7 + 1)


(m, d) = list(map(int, input().split()))
ans = -1
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	if d == 7 or d == 6:
		ans = 6
	else:
		ans = 5
elif m == 2:
	if d == 1:
		ans = 4
	else:
		ans = 5
elif d == 7:
	ans = 6
else:
	ans = 5
print(ans)


import math
(m, d) = map(int, input().split())
if m == 2:
	a = 28
elif m == 4 or m == 6 or m == 9 or (m == 11):
	a = 30
else:
	a = 31
b = a + d - 1
c = b / 7
d = math.ceil(c)
print(d)


import math
months = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(month, weekday) = map(int, input().split())
print(math.ceil((weekday + months[month] - 1) / 7))


(m, d) = map(int, input().split())
days31 = [1, 3, 5, 7, 8, 10, 12]
if m == 2 and d < 2:
	print(4)
elif m == 2 and d > 2:
	print(5)
elif m in days31 and d < 6:
	print(5)
elif m in days31 and d >= 6:
	print(6)
elif m not in days31 and d < 7:
	print(5)
elif m not in days31 and d >= 7:
	print(6)


(m, d) = map(int, input().split())
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	if d == 7 or d == 6:
		print(6)
	else:
		print(5)
elif m == 4 or m == 6 or m == 9 or (m == 11):
	if d == 7:
		print(6)
	else:
		print(5)
elif m == 2:
	if d > 1:
		print(5)
	else:
		print(4)


(month, day) = map(int, input().split())
ans = 1
cnt = 1
kostyl = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
while cnt <= kostyl[month]:
	day += 1
	if day > 7 and cnt != kostyl[month]:
		day = 1
		ans += 1
	cnt += 1
print(ans)


lens = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = [int(s) for s in input().split(' ')]
print((lens[m - 1] + d - 2) // 7 - (d - 1) // 7 + 1)


(m, d) = map(int, input().split())
total = 0
if m in [1, 3, 5, 7, 8, 10, 12]:
	total = 31
elif m == 2:
	total = 28
else:
	total = 30
total -= 8 - d
c = 1
if total % 7 == 0:
	c += total // 7
else:
	c += total // 7 + 1
print(c)


f = lambda : map(int, input().split())
(m, d) = f()
d1 = [1, 3, 5, 7, 8, 10, 12]
if m == 2 and d == 1:
	print(4)
elif m == 2:
	print(5)
elif not m in d1 and d <= 6:
	print(5)
elif not m in d1 and d > 6:
	print(6)
elif m in d1 and d <= 5:
	print(5)
elif m in d1 and d > 5:
	print(6)
else:
	print(6)


(m, d) = map(int, input().split())
cnt = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m]
ans = 1
cnt -= 8 - d
while cnt > 0:
	ans += 1
	cnt -= 7
print(ans)


a = [int(i) for i in input().split()]
m = int(a[0])
d = int(a[1])
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	if d <= 5:
		print('5')
	else:
		print('6')
if m == 2:
	if d == 1:
		print('4')
	else:
		print('5')
if m == 4 or m == 6 or m == 9 or (m == 11):
	if d <= 6:
		print('5')
	else:
		print('6')


(m, d) = map(int, input().split())
lst = [4, 6, 9, 11]
lst1 = [1, 3, 5, 7, 8, 10, 12]
lst2 = [2]
if m in lst:
	if d == 7:
		print(6)
	else:
		print(5)
elif m in lst1:
	if d >= 6:
		print(6)
	else:
		print(5)
elif m in lst2:
	if d == 1:
		print(4)
	else:
		print(5)


import math
(m, d) = map(int, input().split())
if m == 2:
	print(math.ceil((20 + d) / 7) + 1)
elif m in [1, 3, 5, 7, 8, 10, 12]:
	print(math.ceil((23 + d) / 7) + 1)
else:
	print(math.ceil((22 + d) / 7) + 1)


import sys
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
day = [7, 6, 5, 4, 3, 2, 1]
(m, d) = map(int, input().split())
d1 = day[d - 1]
m1 = month[m - 1]
a = m1 - d1
if a % 7 == 0:
	res = 1 + a / 7
else:
	res = int(2 + a / 7)
print(int(res))


a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
als = a[m - 1]
als -= 7 - d + 1
print(2 + (als - 1) // 7)


import math
dates = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
(m, n) = map(int, input().split())
days = dates[m] - (7 - n + 1)
print(math.ceil(days / 7) + 1)


import re
entrada = input()
match = re.search('(\\d*) (\\d*)', entrada)
m = int(match.group(1))
d = int(match.group(2))
meses = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
colunas = (meses[m] - (7 - (d - 1))) // 7 + 1
if (meses[m] - (7 - (d - 1))) % 7 > 0:
	colunas += 1
print(colunas)


(m, d) = [int(x) for x in input().split()]
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	if d <= 5:
		print(5)
	else:
		print(6)
elif m == 2:
	if d == 1:
		print(4)
	else:
		print(5)
elif d <= 6:
	print(5)
else:
	print(6)


month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
tot = month[m - 1]
c = d
ans = 1
while tot > 0:
	c += 1
	tot -= 1
	if c == 8 and tot != 0:
		c = 1
		ans += 1
print(ans)


(m, d) = map(int, input().split())
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print((d - 1 + l[m - 1] - 1) // 7 + 1)


(n, m) = map(int, input().strip().split())
if n == 1 or n == 3 or n == 5 or (n == 7) or (n == 8) or (n == 10) or (n == 12):
	d = 31
elif n == 2:
	d = 28
else:
	d = 30
if (d - 8 + m) % 7 == 0:
	print(1 + (d - 8 + m) // 7)
else:
	print(2 + (d - 8 + m) // 7)


import math
(m, d) = map(int, input().split())
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
x = (l[m - 1] - (8 - d)) / 7.0
print(1 + math.ceil(x))


months = {'1': 31, '2': 28, '3': 31, '4': 30, '5': 31, '6': 30, '7': 31, '8': 31, '9': 30, '10': 31, '11': 30, '12': 31}
(month, day) = input().split()
day = int(day)
if months[month] == 31:
	if day > 5:
		print(6)
	else:
		print(5)
elif months[month] == 30:
	if day > 6:
		print(6)
	else:
		print(5)
elif day >= 2:
	print(5)
else:
	print(4)


days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = input().split(' ')
print(round((days[int(m) - 1] - (8 - int(d))) / 7 + 1.49))


a = input()
s = ''
for i in range(0, len(a)):
	if a[i] == ' ':
		mes = int(s)
		s = ''
		continue
	else:
		s += a[i]
if mes == 1 or mes == 3 or mes == 5 or (mes == 7) or (mes == 8) or (mes == 10) or (mes == 12):
	if int(s) > 5:
		print(6)
	else:
		print(5)
elif mes == 4 or mes == 6 or mes == 9 or (mes == 11):
	if int(s) > 6:
		print(6)
	else:
		print(5)
elif mes == 2:
	if int(s) == 1:
		print(4)
	else:
		print(5)
else:
	print(5)


(a, b) = map(int, input().split())
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
t = a - 1
k = 1
for i in range(l[t]):
	if b > 7:
		b = 1
		k += 1
	b += 1
print(k)


import math
(m, d) = list(map(int, input().split()))
mon = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print(math.ceil((mon[m - 1] - (7 - d + 1)) / 7) + 1)


a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(n, m) = map(int, input().split())
r = a[n - 1]
t = 8 - m
u = r - t
y = u % 7
g = int(u / 7)
if y == 0:
	print(g + 1)
else:
	print(g + 2)


import sys
import re
import math
import itertools
import collections
import bisect
mod = 1000000007
pi = 3.141592653589793
IS = float('inf')
xy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
bs = [(-1, -1), (-1, 1), (1, 1), (1, -1)]

def niten(a, b):
	return abs(a - b) if a >= 0 and b >= 0 else a + abs(b) if a >= 0 else abs(a) + b if b >= 0 else abs(abs(a) - abs(b))

def fib(n):
	return [(seq.append(seq[i - 2] + seq[i - 1]), seq[i - 2])[1] for seq in [[0, 1]] for i in range(2, n)]

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

def lcm(a, b):
	return a * b / gcd(a, b)

def eucl(x1, y1, x2, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

def choco(xa, ya, xb, yb, xc, yc, xd, yd):
	return 1 if abs((yb - ya) * (yd - yc) + (xb - xa) * (xd - xc)) < 1e-10 else 0

def pscl(num, l=[1]):
	for i in range(num):
		l = map(lambda x, y: x + y, [0] + l, l + [0])
	return l
(m, d) = [int(i) for i in input().split()]
m0 = [4, 6, 9, 11]
m1 = [1, 3, 5, 7, 8, 10, 12]
if m in m0:
	if d == 7:
		ans = 6
	else:
		ans = 5
elif m in m1:
	if d >= 6:
		ans = 6
	else:
		ans = 5
elif d == 1:
	ans = 4
else:
	ans = 5
print(ans)


(a, b) = map(int, input().split())
if b <= 5 and a != 2:
	print(5)
elif a == 2:
	if b == 1:
		print(4)
	else:
		print(5)
elif a in [1, 3, 5, 7, 8, 10, 12]:
	print(6)
elif b == 6:
	print(5)
else:
	print(6)


inputLine = input()
inputLine = inputLine.split()
m = int(inputLine[0])
n = int(inputLine[1])
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	if n <= 5:
		print(5)
	else:
		print(6)
elif m == 2:
	if n == 1:
		print(4)
	else:
		print(5)
elif n <= 6:
	print(5)
else:
	print(6)


(m, d) = map(int, input().split())
d -= 1
l = 30
if m == 2:
	l = 28
if m in {1, 3, 5, 7, 8, 10, 12}:
	l = 31
res = 1
l -= 7 - d
res += l // 7
l %= 7
if l != 0:
	res += 1
print(res)


(m, d) = map(int, input().split())
m1_l = [1, 3, 5, 7, 8, 10, 12]
m0_l = [4, 6, 9, 11]
c = 4
if m in m1_l:
	y = 31 % 7
	y = y - (7 - d + 1)
	c = c + 1
	if y > 0:
		c = c + 1
elif m in m0_l:
	y = 30 % 7
	y = y - (7 - d + 1)
	c = c + 1
	if y > 0:
		c = c + 1
elif d != 1:
	c = c + 1
print(c)


(m, d) = map(int, input().split())
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
res = d - 1 + month[m - 1]
if res % 7 > 0:
	print(res // 7 + 1)
else:
	print(res // 7)


(m, d) = map(int, input().split(' '))
l = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
x = 1 + (l[m] - 8 + d) // 7
if (l[m] - 8 + d) % 7 > 0:
	x += 1
print(x)


import math
m = [-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(a, b) = map(int, input().split())
b = 8 - b
print(math.ceil((m[a] - b) / 7) + 1)


(m, d) = map(int, input().split())
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = l[m - 1]
days += d - 1
if days % 7 == 0:
	print(days // 7)
else:
	print(days // 7 + 1)


(m, d) = map(int, input().split())
mo1 = [1, 3, 5, 7, 8, 10, 12]
mo2 = [4, 6, 9, 11]
if m in mo1:
	k = 31
elif m in mo2:
	k = 30
else:
	k = 28
if (k + d - 1) % 7 == 0:
	ans = (k + d - 1) // 7
else:
	ans = (k + d - 1) // 7 + 1
print(ans)


n = input().split()
k = int(n[0])
h = int(n[1])
if k == 1 or k == 3 or k == 5 or (k == 7) or (k == 8) or (k == 10) or (k == 12):
	if h == 6 or h == 7:
		print(6)
	else:
		print(5)
if k == 2:
	if h == 1:
		print(4)
	else:
		print(5)
if k == 4 or k == 6 or k == 9 or (k == 11):
	if h == 7:
		print(6)
	else:
		print(5)


import math
(month, day) = input().split()
(month, day) = (int(month), int(day))
if month == 1 or month == 3 or month == 5 or (month == 7) or (month == 8) or (month == 10) or (month == 12):
	total = 30 + day
elif month == 2:
	total = 27 + day
else:
	total = 29 + day
col = math.ceil(total / 7)
print(col)


(m, d) = input().split()
m = int(m)
d = int(d)
days = 0
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	days = 31
elif m == 2:
	days = 28
else:
	days = 30
days += d - 1
weeks = days // 7
if days % 7 > 0:
	weeks += 1
print(weeks)


(a, b) = map(int, input().split())
x = 1
if a == 1 or a == 3 or a == 5 or (a == 7) or (a == 8) or (a == 10) or (a == 12):
	m = 31 - abs(b - 8)
	if m % 7 >= 1:
		print(x + m // 7 + 1)
	else:
		print(x + m // 7)
if a == 4 or a == 6 or a == 9 or (a == 11):
	m = 30 - abs(b - 8)
	if m % 7 >= 1:
		print(x + m // 7 + 1)
	else:
		print(x + m // 7)
if a == 2:
	m = 28 - abs(b - 8)
	if m % 7 >= 1:
		print(x + m // 7 + 1)
	else:
		print(x + m // 7)


import sys

def main():
	(m, d) = map(int, sys.stdin.readline().split())
	x = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	y = x[m - 1] + d - 1
	res = y / 7
	if res > int(res):
		res = int(res) + 1
	print(int(res))
main()


import sys
from math import ceil
days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = list(map(int, input().split()))
days = d - 1 + days[m]
print(ceil(days / 7))


(m, d) = map(int, input().split())
m31 = [1, 3, 5, 7, 8, 10, 12]
m30 = [4, 6, 9, 11]
if m in m31:
	days = 31 - (8 - d)
	if days % 7 == 0:
		print(days // 7 + 1)
	else:
		print(days // 7 + 2)
elif m in m30:
	days = 30 - (8 - d)
	if days % 7 == 0:
		print(days // 7 + 1)
	else:
		print(days // 7 + 2)
else:
	days = 28 - (8 - d)
	if days % 7 == 0:
		print(days // 7 + 1)
	else:
		print(days // 7 + 2)


(m, d) = map(int, input().split())
mn = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ds = mn[m - 1]
rs = 1
ds -= 7 - d + 1
rs += ds // 7
if ds % 7 != 0:
	rs += 1
print(rs)


from math import *
(m, d) = map(int, input().split())
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	ans = 31
elif m == 2:
	ans = 28
else:
	ans = 30
ans -= 8 - d
cnt = 1
cnt += (ans + 6) // 7
print(cnt)


(m, d) = map(int, input().split())
m31 = [1, 3, 5, 7, 8, 10, 12]
m30 = [4, 6, 9, 11]
if m in m31:
	if d == 6 or d == 7:
		print(6)
	else:
		print(5)
if m in m30:
	if d == 7:
		print(6)
	else:
		print(5)
if m == 2:
	if d == 1:
		print(4)
	else:
		print(5)


(n, k) = map(int, input().split())
a = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
dienos = a[n]
j = 0
i = k - 1
for t in range(a[n]):
	if i == 7:
		j += 1
		i = 0
	if t == a[n] - 1 and i != 7:
		j += 1
	i += 1
print(j)


def ri():
	return map(int, input().split())
dates = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = ri()
tot = dates[m - 1] + d - 1
ans = tot // 7
if tot % 7:
	ans += 1
print(ans)


(m, n) = map(int, input().split())
if m == 2:
	if n == 1:
		print(4)
	else:
		print(5)
elif m <= 7 and m % 2 or (m > 7 and m % 2 == 0):
	if n <= 5:
		print(5)
	else:
		print(6)
elif n <= 6:
	print(5)
else:
	print(6)


(n, m) = map(int, input().split())
l = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
k = l[n] + m - 1
if k % 7 == 0:
	print(k // 7)
else:
	print(k // 7 + 1)


(n, m) = [int(i) for i in input().split()]
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = l[n - 1]
k = 1
days = days - 8 + m
while 0 < days:
	days = days - 7
	k += 1
print(k)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
if n == 2:
	if m == 1:
		print(4)
	else:
		print(5)
	exit()
if m == 7:
	print(6)
elif m == 6:
	if n <= 7:
		print(6 if n % 2 != 0 else 5)
	else:
		print(5 if n % 2 != 0 else 6)
else:
	print(5)


(m, d) = map(int, input().split())
god = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
sum = 1
g = god[m] - (8 - d)
sum += g // 7
if g % 7 != 0:
	sum += 1
print(sum)


n = list(map(int, input().split()))
s = [1, 3, 5, 7, 8, 10, 12]
v = [4, 6, 9, 11]
d = 0
if n[0] in s:
	if n[1] != 1:
		w = 7 - n[1]
		m = 31 - (w + 1)
		while True:
			m = m - 7
			d = d + 1
			if m <= 0:
				print(d + 1)
				break
	else:
		m = 31
		while True:
			m = m - 7
			d = d + 1
			if m <= 0:
				print(d)
				break
elif n[0] in v:
	if n[1] != 1:
		w = 7 - n[1]
		m = 30 - (w + 1)
		while True:
			m = m - 7
			d = d + 1
			if m <= 0:
				print(d + 1)
				break
	else:
		m = 30
		while True:
			m = m - 7
			d = d + 1
			if m <= 0:
				print(d)
				break
elif n[1] != 1:
	w = 7 - n[1]
	m = 29 - (w + 1)
	while True:
		m = m - 7
		d = d + 1
		if m <= 0:
			print(d + 1)
			break
else:
	m = 28
	while True:
		m = m - 7
		d = d + 1
		if m <= 0:
			print(d)
			break


(m, d) = map(int, input().split())
l0 = [1, 3, 5, 7, 8, 10, 12]
l1 = [4, 6, 9, 11]
l2 = [2]
if m in l0:
	if d > 5:
		print(6)
	if d <= 5:
		print(5)
elif m in l1:
	if d > 6:
		print(6)
	if d <= 6:
		print(5)
elif m in l2:
	if d <= 1:
		print(4)
	else:
		print(5)


(n, m) = map(int, input().split())
ds = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
e = ds[n - 1]
q = e - (8 - m)
r = q // 7
ans = 1 + r
if q % 7 != 0:
	ans += 1
print(ans)


from math import ceil
(m, d) = map(int, input().split())
ol = [1, 3, 5, 7, 8, 10, 12]
el = [4, 6, 9, 11]
feb = 2
if m in ol:
	days = 31
	days -= 8 - d
	print(ceil(days / 7) + 1)
elif m in el:
	days = 30
	days -= 8 - d
	print(ceil(days / 7) + 1)
else:
	days = 28
	days -= 8 - d
	print(ceil(days / 7) + 1)


(m, d) = tuple(map(int, input().split()))
days = -1
if m in [1, 3, 5, 7, 8, 10, 12]:
	days = 31
elif m == 2:
	days = 28
else:
	days = 30
res = days + (d - 1)
if res % 7 == 0:
	print(res // 7)
else:
	print(res // 7 + 1)


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
cnt = k - 8
if n == 1 or n == 3 or n == 5 or (n == 7) or (n == 8) or (n == 10) or (n == 12):
	cnt += 31
elif n == 2:
	cnt += 28
else:
	cnt += 30
if cnt % 7:
	ans = 2 + cnt // 7
else:
	ans = 1 + cnt // 7
stdout.write(str(ans))


(m, d) = map(int, input().split())
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if m == 2 and d == 1:
	print(4)
elif d <= 5 + (31 - days[m - 1]):
	print(5)
else:
	print(6)


(m, d) = map(int, input().split())
months = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
print((d - 2 + months[m]) // 7 + 1)


(m, d) = map(int, input().split())
dulji = [1, 3, 5, 7, 8, 10, 12]
kraci = [4, 6, 9, 11]
dani = 0
if m == 2:
	dani = 28
elif m in dulji:
	dani = 31
else:
	dani = 30
dani = dani + (d - 1)
if dani % 7 == 0:
	print(dani // 7)
else:
	print(dani // 7 + 1)


(m, d) = input().split(' ')
(m, d) = (int(m), int(d))
month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
week = 1
i = 0
while i < month[m]:
	d += 1
	if d > 7 and i < month[m] - 1:
		d = 1
		week += 1
	i += 1
print(week)


ip = input().split(' ')
ip = list(map(int, ip))
ndays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = ndays[ip[0] - 1] + ip[1] - 1
columns = 0
while days > 0:
	days = days - 7
	columns += 1
print(columns)


(m, d) = input().split()
m = int(m)
d = int(d)
c = 0
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	c = 5
	if d > 5:
		c = 6
if m == 2:
	c = 4
	if d > 1:
		c = 5
if m == 4 or m == 6 or m == 9 or (m == 11):
	c = 5
	if d == 7:
		c = 6
print(c)


def main():
	days_in_month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	[month, first_day] = [int(_) for _ in input().split()]
	n_days = days_in_month[month]
	n_weeks = 1
	n_days -= 8 - first_day
	n_weeks += n_days // 7
	n_days %= 7
	if n_days > 0:
		n_weeks += 1
	print(n_weeks)
main()


import sys
r = lambda : sys.stdin.readline().strip()
wr = lambda x: sys.stdout.write(str(x) + '\n')
table = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, r().split())
days = table[m - 1]
(q, r) = (days // 7, days % 7)
if r == 0:
	if d == 1:
		wr(4)
	else:
		wr(5)
elif r == 2:
	if d <= 6:
		wr(5)
	else:
		wr(6)
elif r == 3:
	if d <= 5:
		wr(5)
	else:
		wr(6)


a = list(map(int, input().split()))
dayinm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
answ = (dayinm[a[0] - 1] - (8 - a[1]) + 6) // 7 + 1
print(answ)


__author__ = 'zihaozhu'
from sys import stdin
long = set([1, 3, 5, 7, 8, 10, 12])
feb = [2]
short = set([4, 6, 9, 11])
(month, day) = map(int, stdin.readline().split())
if month in long:
	days = 31
	first = 8 - day
	remaining = (days - first) % 7
	mod = (days - first) // 7
	if remaining == 0:
		print(mod + 1)
	else:
		print(mod + 2)
elif month in feb:
	days = 28
	first = 8 - day
	remaining = (days - first) % 7
	mod = (days - first) // 7
	if remaining == 0:
		print(mod + 1)
	else:
		print(mod + 2)
elif month in short:
	days = 30
	first = 8 - day
	remaining = (days - first) % 7
	mod = (days - first) // 7
	if remaining == 0:
		print(mod + 1)
	else:
		print(mod + 2)


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))
(m, d) = get_int_list()
a = {1, 3, 5, 7, 8, 10, 12}
if m in a:
	if d >= 6:
		print(6)
	else:
		print(5)
elif m == 2:
	if d == 1:
		print(4)
	else:
		print(5)
elif d == 7:
	print(6)
else:
	print(5)


array = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
a = input()
for i in range(0, len(a)):
	if a[i] == ' ':
		break
b = array[int(a[0:i]) - 1]
c = int(a[i + 1:])
b -= 8 - c
d = 1
while b > 7:
	d += 1
	b -= 7
d += 1
print(d)


month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
max_day = d - 1 + month_days[m - 1]
print(max_day // 7 if max_day % 7 == 0 else max_day // 7 + 1)


import sys
fin = sys.stdin
fout = sys.stdout
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, fin.readline().split())
ans = (days[m - 1] - (7 - d + 1)) // 7 + 1
if (days[m - 1] - (7 - d + 1)) % 7 != 0:
	ans += 1
fout.write(str(ans))


def main():
	a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	(n, k) = map(int, input().split())
	print(1 + (a[n - 1] - (8 - k) + 6) // 7)
	return 0
main()


n31 = {1, 3, 5, 7, 8, 10, 12}
n30 = {4, 6, 8, 9, 11}
n28 = {2}
(m, d) = map(int, input().split())
used = 8 - d
if m in n31:
	curD = 31 - used
elif m in n30:
	curD = 30 - used
else:
	curD = 28 - used
if curD % 7 == 0:
	print(1 + curD // 7)
else:
	print(2 + curD // 7)


(a, b) = map(int, input().split())
x = [1, 3, 5, 7, 8, 10, 12]
y = [4, 6, 9, 11]
if a == 2:
	print(4 if b == 1 else 5)
elif a in x:
	print(6 if b >= 6 else 5)
else:
	print(6 if b == 7 else 5)


def Main(m, d):
	month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	day = [1, 2, 3, 4, 5, 6, 7]
	M = month[m - 1]
	if M == 31 and (d == 6 or d == 7):
		print(6)
		return 0
	if M == 31 and 1 <= d <= 5:
		print(5)
		return 0
	if M == 30 and d == 7:
		print(6)
		return 0
	if M == 30 and 1 <= d <= 6:
		print(5)
		return 0
	if M == 28 and d == 1:
		print(4)
		return 0
	if M == 28 and 2 <= d <= 7:
		print(5)
(m, d) = map(int, input().split())
Main(m, d)


days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(month, first) = map(int, input().split())
first -= 1
cnt = 1
x = days[month - 1] - (7 - first)
cnt += x // 7
if x % 7 != 0:
	cnt += 1
print(cnt)


a = list(map(int, input().split()))
dayinm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
answ = (dayinm[a[0] - 1] + a[1] - 2) // 7 + 1
print(answ)


(month, cur) = list(map(int, input().split()))
month_day = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
col = 1
for i in range(1, month_day[month] + 1):
	if cur == 8:
		cur = 2
		col += 1
	else:
		cur += 1
print(col)


refer = (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
(m, d) = map(int, input().split())
n = refer[m] + d - 8
for i in range(1, 7):
	if n <= 0:
		print(i)
		break
	n -= 7


nbD = dict()
for i in [1, 3, 5, 7, 8, 10, 12]:
	nbD[i] = 31
for i in [4, 6, 9, 11]:
	nbD[i] = 30
nbD[2] = 28
(m, d) = map(int, input().split())
tot = nbD[m]
first = 8 - d
nbW = 1
tot -= first
nbW += (tot + 6) // 7
print(nbW)


from math import ceil
(m, wd) = input().split()
m = int(m)
wd = int(wd)
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	l = list(range(1, 32))
	for i in range(1, wd):
		l.insert(0, 0)
	print(ceil(len(l) / 7))
elif m == 4 or m == 6 or m == 9 or (m == 11):
	l = list(range(1, 31))
	for i in range(1, wd):
		l.insert(0, 0)
	print(ceil(len(l) / 7))
else:
	l = list(range(1, 29))
	for i in range(1, wd):
		l.insert(0, 0)
	print(ceil(len(l) / 7))


import math
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
string = input()
numbers = string.split()
(a, b) = (int(numbers[0]), int(numbers[1]))
print(math.ceil((months[a - 1] + b - 8) / 7) + 1)


(a, b) = map(int, input().split())
d = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][a - 1]
print((d - (8 - b)) // 7 + 1 + int((d - (8 - b)) % 7 != 0))


(n, m) = map(int, input().split())
a = [[0] * 7] * 6
s = 0
if n == 2:
	for i in range(6):
		for j in range(7):
			if m == 1:
				s += 1
				a[i][j] = s
			else:
				m -= 1
			if s == 28:
				print(i + 1)
				exit()
elif n % 2 == 0:
	if n <= 7:
		for i in range(6):
			for j in range(7):
				if m == 1:
					s += 1
					a[i][j] = s
				else:
					m -= 1
				if s == 30:
					print(i + 1)
					exit()
	else:
		for i in range(6):
			for j in range(7):
				if m == 1:
					s += 1
					a[i][j] = s
				else:
					m -= 1
				if s == 31:
					print(i + 1)
					exit()
elif n <= 7:
	for i in range(6):
		for j in range(7):
			if m == 1:
				s += 1
				a[i][j] = s
			else:
				m -= 1
			if s == 31:
				print(i + 1)
				exit()
else:
	for i in range(6):
		for j in range(7):
			if m == 1:
				s += 1
				a[i][j] = s
			else:
				m -= 1
			if s == 30:
				print(i + 1)
				exit()


(m, day) = map(int, input().split())
g = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print((g[m - 1] - 1 - (7 - day + 1)) // 7 + 2)


a = [30, 31] * 9
a[2] = 28
a[8:] = [31, 30] * 3
(m, d) = map(int, input().split())
print(1 - -(a[m] + d - 8) // 7)


from math import *
m31 = [1, 3, 5, 7, 8, 10, 12]
m30 = [4, 6, 9, 11]
m29 = [2]
(m, d) = [int(i) for i in input().split()]
if m in m31:
	d = 23 + d
	print(ceil(d / 7) + 1)
elif m in m30:
	d = 22 + d
	print(ceil(d / 7) + 1)
else:
	d += 20
	print(ceil(d / 7) + 1)


months = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
(m, d) = [int(x) for x in input().split(' ')]
d1 = 7 - d + 1
count = 1
d2 = months[m] - d1
count += int(d2 / 7)
rem = d2 % 7
if rem != 0:
	count += 1
print(count)


import math
(m, d) = [int(i) for i in input().split()]
mon = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
al = mon[m - 1]
weeks = math.ceil((al - (7 - d + 1)) / 7) + 1
print(weeks)


(m, d) = map(int, input().split())
print(((3, 0, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3)[m - 1] + d + 5) // 7 + 4)


(n, m) = map(int, input().split())
if n in (1, 3, 5, 7, 8, 10, 12):
	days = 31
elif n == 2:
	days = 28
else:
	days = 30
column = 1
days -= 8 - m
if days % 7:
	column += 1
column += days // 7
print(column)


import math
(m, d) = map(int, input().split(' '))
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1]
first = 7 - d + 1
print(int(math.ceil((days - first) / 7)) + 1)


(n, m) = list(map(int, input().split()))
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = days[n - 1]
first = 7 - m + 1
last = days - first
weeks = last // 7 + 1
if last % 7 != 0:
	weeks += 1
print(weeks)


(m, d) = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
if m in a:
	print((d + 29) // 7 + 1)
elif m == 2:
	print(4 if d == 1 else 5)
else:
	print((d + 28) // 7 + 1)


import math

def solve(m, d):
	months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	rem = 0
	count = 4
	if months[m - 1] == 31:
		rem = 4
		count = 5
	elif months[m - 1] == 30:
		rem = 5
		count = 5
	if d - 1 > rem:
		count += 1
	return count

def main():
	i = list(map(int, input().split(' ')))
	print(solve(*i))
main()


def countweek(d, total):
	first = 7 - d + 1
	rest = total - first
	weeks = 1 + rest // 7
	if rest % 7 > 0:
		weeks += 1
	return weeks
(m, d) = input().split()
m = int(m)
d = int(d)
weeks = 0
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	weeks = countweek(d, 31)
elif m == 2:
	weeks = countweek(d, 28)
else:
	weeks = countweek(d, 30)
print(weeks)


nd = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
m -= 1
c = 1
num = 1
while True:
	num += 1
	if num > nd[m]:
		break
	d += 1
	if d > 7:
		d -= 7
		c += 1
print(c)


def solution(l1):
	big = [1, 3, 5, 7, 8, 10, 12]
	small = [2, 4, 6, 9, 11]
	if l1[0] in big:
		size = 31
	elif l1[0] == 2:
		size = 28
	else:
		size = 30
	cells = l1[1] + size - 1
	ans = int(cells / 7) + (cells % 7 != 0) * 1
	return ans

def answer():
	l1 = [int(x) for x in input().split()]
	print(solution(l1))
answer()


(m, d) = map(int, input().split())
l = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ans = 1
t = l[m]
t -= 8 - d
while t > 0:
	t -= 7
	ans += 1
print(ans)


(m, d) = list(map(int, input().split()))
dd = 31
if m == 2:
	dd = 28
if m == 4 or m == 6 or m == 9 or (m == 11):
	dd = 30
(a, dd) = (1, dd - (8 - d))
while dd > 0:
	(a, dd) = (a + 1, dd - 7)
print(a)


import math
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
n = [int(x) for x in input().split()]
print(math.ceil((month[n[0] - 1] + n[1] - 1) / 7))


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
ABCD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
MOD = 1000000007
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
months = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
(x, y) = map(int, input().split(' '))
ans = 1 + math.ceil((months[x] - 7 - 1 + y) / 7)
print(ans)


def check_month(day, month):
	return sum(months[:month]) <= day < sum(months[:month + 1])
A = [0] * 365
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(365):
	A[i] = i % 7
(m, d) = map(int, input().split())
m -= 1
first_day = 0
while not check_month(first_day, m):
	first_day += 1
diff = d - A[first_day]
for i in range(365):
	A[i] += diff
	A[i] %= 7
sundays = 0
for i in range(365):
	if check_month(i, m):
		if A[i] == 0:
			sundays += 1
while check_month(first_day, m):
	first_day += 1
first_day -= 1
if A[first_day] != 0:
	sundays += 1
print(sundays)


(m, d) = map(int, input().split())
if m == 2:
	wm = 28
elif m == 4 or m == 6 or m == 9 or (m == 11):
	wm = 30
else:
	wm = 31
wm -= 8 - d
if wm % 7 == 0:
	print(1 + wm // 7)
else:
	print(2 + wm // 7)


(m, d) = map(int, input().split())
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
x = 8 - d
y = a[m - 1] - x
z = y // 7
if y % 7 != 0:
	z = z + 1
print(z + 1)


(m, d) = [int(s) for s in input().split(' ')]
days = 31
if m in [4, 6, 9, 11]:
	days = 30
elif m == 2:
	days = 28
ans = 1
days -= 7 - d + 1
ans += days // 7
if days % 7:
	ans += 1
print(ans)


(month, first_day) = (int(x) for x in input().split())
month_to_len = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
len_to_start = {28: 1, 30: 6, 31: 5}
len_to_min_columns = {28: 4, 30: 5, 31: 5}
month_len = month_to_len[month]
columns_nr = len_to_min_columns[month_len]
if first_day > len_to_start[month_len]:
	columns_nr += 1
	print(columns_nr)
else:
	print(columns_nr)


k = [1, 3, 5, 7, 8, 10, 12]
(m, d) = map(int, input().split())
if m == 2:
	days = 28
elif m in k:
	days = 31
else:
	days = 30
dif = 8 - d
c = 1
days = days - dif
while True:
	if days - 7 < 0:
		c = c + 1
		break
	else:
		days = days - 7
		c = c + 1
		if days == 0:
			break
print(c)


from operator import itemgetter
(m, d) = map(int, input().split())
days = 31
if m == 2:
	days = 28
elif m == 4 or m == 6 or m == 9 or (m == 11):
	days = 30
days -= 8 - d
print(1 + days // 7 + (days % 7 != 0))


(m, d) = map(int, input().split())
if m == 1:
	n = 31
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 2:
	n = 28
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 3:
	n = 31
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 4:
	n = 30
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 5:
	n = 31
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 6:
	n = 30
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 7:
	n = 31
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 8:
	n = 31
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 9:
	n = 30
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 10:
	n = 31
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 11:
	n = 30
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)
if m == 12:
	n = 31
	ex = 0
	if d != 1:
		val = 8 - d
		n -= val
		ex = 1
	np = n % 7
	if np:
		print(n // 7 + 1 + ex)
	else:
		print(n // 7 + ex)


a = [int(i) for i in input().split()]
m = int(a[0])
d = int(a[1])
j = 1
if m == 1 or m == 3 or m == 5 or (m == 7) or (m == 8) or (m == 10) or (m == 12):
	for i in range(30):
		d += 1
		if d > 7:
			d -= 7
			j += 1
if m == 4 or m == 6 or m == 9 or (m == 11):
	for i in range(29):
		d += 1
		if d > 7:
			d -= 7
			j += 1
if m == 2:
	for i in range(27):
		d += 1
		if d > 7:
			d -= 7
			j += 1
print(j)


import math
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(m, d) = map(int, input().split())
k = 7 - d + 1
i = m - 1
n = a[i] - k
p = math.floor(n / 7)
if p * 7 != n:
	p += 1
print(p + 1, end='')


(m, d) = [int(x) for x in input().split()]
md = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
n = (md[m - 1] - (8 - d)) // 7
if (md[m - 1] - (8 - d)) % 7 == 0:
	print(n + 1)
else:
	print(n + 2)