a,b = (int(i) for i in input().split())
if a == 2:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 2
	elif b == 4:
		ans = 3
	elif b == 5:
		ans = 4
	elif b == 6:
		ans = 5
	elif b == 7:
		ans = 6
	elif b == 8:
		ans = 7
	elif b == 9:
		ans = 8
	elif b == 10:
		ans = 9
	elif b == 11:
		ans = 10
	elif b == 12:
		ans = 11
	elif b == 13:
		ans = 12
	elif b == 14:
		ans = 13
	elif b == 15:
		ans = 14
	elif b == 16:
		ans = 15
	elif b == 17:
		ans = 16
	elif b == 18:
		ans = 17
	elif b == 19:
		ans = 18
	elif b == 20:
		ans = 19
elif a == 3:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 2
	elif b == 5:
		ans = 2
	elif b == 6:
		ans = 3
	elif b == 7:
		ans = 3
	elif b == 8:
		ans = 4
	elif b == 9:
		ans = 4
	elif b == 10:
		ans = 5
	elif b == 11:
		ans = 5
	elif b == 12:
		ans = 6
	elif b == 13:
		ans = 6
	elif b == 14:
		ans = 7
	elif b == 15:
		ans = 7
	elif b == 16:
		ans = 8
	elif b == 17:
		ans = 8
	elif b == 18:
		ans = 9
	elif b == 19:
		ans = 9
	elif b == 20:
		ans = 10
elif a == 4:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 2
	elif b == 6:
		ans = 2
	elif b == 7:
		ans = 2
	elif b == 8:
		ans = 3
	elif b == 9:
		ans = 3
	elif b == 10:
		ans = 3
	elif b == 11:
		ans = 4
	elif b == 12:
		ans = 4
	elif b == 13:
		ans = 4
	elif b == 14:
		ans = 5
	elif b == 15:
		ans = 5
	elif b == 16:
		ans = 5
	elif b == 17:
		ans = 6
	elif b == 18:
		ans = 6
	elif b == 19:
		ans = 6
	elif b == 20:
		ans = 7
elif a == 5:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 2
	elif b == 7:
		ans = 2
	elif b == 8:
		ans = 2
	elif b == 9:
		ans = 2
	elif b == 10:
		ans = 3
	elif b == 11:
		ans = 3
	elif b == 12:
		ans = 3
	elif b == 13:
		ans = 3
	elif b == 14:
		ans = 4
	elif b == 15:
		ans = 4
	elif b == 16:
		ans = 4
	elif b == 17:
		ans = 4
	elif b == 18:
		ans = 5
	elif b == 19:
		ans = 5
	elif b == 20:
		ans = 5
elif a == 6:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 2
	elif b == 8:
		ans = 2
	elif b == 9:
		ans = 2
	elif b == 10:
		ans = 2
	elif b == 11:
		ans = 2
	elif b == 12:
		ans = 3
	elif b == 13:
		ans = 3
	elif b == 14:
		ans = 3
	elif b == 15:
		ans = 3
	elif b == 16:
		ans = 3
	elif b == 17:
		ans = 4
	elif b == 18:
		ans = 4
	elif b == 19:
		ans = 4
	elif b == 20:
		ans = 4
elif a == 7:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 2
	elif b == 9:
		ans = 2
	elif b == 10:
		ans = 2
	elif b == 11:
		ans = 2
	elif b == 12:
		ans = 2
	elif b == 13:
		ans = 2
	elif b == 14:
		ans = 3
	elif b == 15:
		ans = 3
	elif b == 16:
		ans = 3
	elif b == 17:
		ans = 3
	elif b == 18:
		ans = 3
	elif b == 19:
		ans = 3
	elif b == 20:
		ans = 4
elif a == 8:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 2
	elif b == 10:
		ans = 2
	elif b == 11:
		ans = 2
	elif b == 12:
		ans = 2
	elif b == 13:
		ans = 2
	elif b == 14:
		ans = 2
	elif b == 15:
		ans = 2
	elif b == 16:
		ans = 3
	elif b == 17:
		ans = 3
	elif b == 18:
		ans = 3
	elif b == 19:
		ans = 3
	elif b == 20:
		ans = 3
elif a == 9:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 2
	elif b == 11:
		ans = 2
	elif b == 12:
		ans = 2
	elif b == 13:
		ans = 2
	elif b == 14:
		ans = 2
	elif b == 15:
		ans = 2
	elif b == 16:
		ans = 2
	elif b == 17:
		ans = 2
	elif b == 18:
		ans = 3
	elif b == 19:
		ans = 3
	elif b == 20:
		ans = 3
elif a == 10:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 2
	elif b == 12:
		ans = 2
	elif b == 13:
		ans = 2
	elif b == 14:
		ans = 2
	elif b == 15:
		ans = 2
	elif b == 16:
		ans = 2
	elif b == 17:
		ans = 2
	elif b == 18:
		ans = 2
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 3
elif a == 11:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 2
	elif b == 13:
		ans = 2
	elif b == 14:
		ans = 2
	elif b == 15:
		ans = 2
	elif b == 16:
		ans = 2
	elif b == 17:
		ans = 2
	elif b == 18:
		ans = 2
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 2
elif a == 12:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 2
	elif b == 14:
		ans = 2
	elif b == 15:
		ans = 2
	elif b == 16:
		ans = 2
	elif b == 17:
		ans = 2
	elif b == 18:
		ans = 2
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 2
elif a == 13:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 1
	elif b == 14:
		ans = 2
	elif b == 15:
		ans = 2
	elif b == 16:
		ans = 2
	elif b == 17:
		ans = 2
	elif b == 18:
		ans = 2
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 2
elif a == 14:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 1
	elif b == 14:
		ans = 1
	elif b == 15:
		ans = 2
	elif b == 16:
		ans = 2
	elif b == 17:
		ans = 2
	elif b == 18:
		ans = 2
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 2
elif a == 15:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 1
	elif b == 14:
		ans = 1
	elif b == 15:
		ans = 1
	elif b == 16:
		ans = 2
	elif b == 17:
		ans = 2
	elif b == 18:
		ans = 2
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 2
elif a == 16:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 1
	elif b == 14:
		ans = 1
	elif b == 15:
		ans = 1
	elif b == 16:
		ans = 1
	elif b == 17:
		ans = 2
	elif b == 18:
		ans = 2
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 2
elif a == 17:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 1
	elif b == 14:
		ans = 1
	elif b == 15:
		ans = 1
	elif b == 16:
		ans = 1
	elif b == 17:
		ans = 1
	elif b == 18:
		ans = 2
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 2
elif a == 18:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 1
	elif b == 14:
		ans = 1
	elif b == 15:
		ans = 1
	elif b == 16:
		ans = 1
	elif b == 17:
		ans = 1
	elif b == 18:
		ans = 1
	elif b == 19:
		ans = 2
	elif b == 20:
		ans = 2
elif a == 19:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 1
	elif b == 14:
		ans = 1
	elif b == 15:
		ans = 1
	elif b == 16:
		ans = 1
	elif b == 17:
		ans = 1
	elif b == 18:
		ans = 1
	elif b == 19:
		ans = 1
	elif b == 20:
		ans = 2
elif a == 20:
	if b == 1:
		ans = 0
	elif b == 2:
		ans = 1
	elif b == 3:
		ans = 1
	elif b == 4:
		ans = 1
	elif b == 5:
		ans = 1
	elif b == 6:
		ans = 1
	elif b == 7:
		ans = 1
	elif b == 8:
		ans = 1
	elif b == 9:
		ans = 1
	elif b == 10:
		ans = 1
	elif b == 11:
		ans = 1
	elif b == 12:
		ans = 1
	elif b == 13:
		ans = 1
	elif b == 14:
		ans = 1
	elif b == 15:
		ans = 1
	elif b == 16:
		ans = 1
	elif b == 17:
		ans = 1
	elif b == 18:
		ans = 1
	elif b == 19:
		ans = 1
	elif b == 20:
		ans = 1
print(ans)

Measured memory_bytes: 38256