# a = int(input())
# n = a // 3600
# b = n
# x = (a % 3600) // 60
# y = a % 60
# print(b, x, y)
# a = int(input())
# b = a // 3600
# n = b
# x = (a % 3600) // 60
# y = a % 60
# print(n, x, y)
import math
# math.sqrt(10)
# 3*3 = 9
# sqrt(9) > 3
# import math
#
# x1, y1 = map(int, input().split())
# x2, y2 = map(int, input().split())
#
# p = math.sqrt((x1-x2) (x1-x2) + (y1-y2) (y1-y2))
# print("{:.2f}".format(p))
a, b = map(int, input().split())
x = 0
y = 0
n = 0
for i in range(a < b):
if a >= b:
a -= 2
print(a)