import string

inputstr = raw_input("")
s = string.split(inputstr, " ")
n = int(s[0]) #
m = int(s[1]) #

if(n == 1):
	print(1)
elif(n == 2):
	if(m == 1):
		print(2)
	elif(m == 2):
		print(1)
else:
	if(n < 2*m):
		print(m-1)
	elif(n >= 2*m):
		print(m+1)
	else:
		print(1)
