One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a.

Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins.

Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible.

More formally, you need to find such integer a (1 ≤ a ≤ n), that the probability that $|c - a|<|c - m|$ is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive).


-----Input-----

The first line contains two integers n and m (1 ≤ m ≤ n ≤ 10^9) — the range of numbers in the game, and the number selected by Misha respectively.


-----Output-----

Print a single number — such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them.


-----Examples-----
Input
3 1

Output
2
Input
4 3

Output
2


-----Note-----

In the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0.

In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less.

Difficulty: interview

Starter code:

Solutions:
n, m = list(map(int, input().split()))
if n == 1:
    print(1)
elif m - 1 >= n - m:
    print(m - 1)
else:
    print(m + 1)


def main():
    n, m = list(map(int, input().split()))
    if n == 1:
        print(1)
    else:
        left, right = max(0, m - 1), max(0, n - m)
        if left >= right:
            print(m - 1)
        else:
            print(m + 1)


def __starting_point():
    main()

__starting_point()

import collections
def f():
    n,m  = [int(c) for c in input().split()]

    if m > n // 2:
        return max(1, m - 1)
    return min(n, m+1)

print(f())

n, m = [int(i) for i  in input().split()]
if n == 1:
    print(1)
else:
    if n-m>m-1:
        print(m+1)
    else:
        print(m-1)


n, m = (int(x) for x in input().split())
if n == 1:
	print(1)
else:
	if m - 1 >= n - m:
		print(max(1, m-1))
	else:
		print(min(m+1, n))


import math
import sys

x=list(map(int,input().split()))
n=x[0]
m=x[1]

if m>int(n/2):
    a=m-1
else:
    a=m+1
if n==1 and m==1:
    a=1
print(a)



    


    


n, m = list(map(int, input().split()))
if n == 1 and m == 1:
    print(1)
elif n - m > m - 1:
    print(m+1)
else:
    print(m-1)

import sys; sys.setrecursionlimit(1000000)
def solve():
    n, m, = rv()
    if n == 1:
        return 1
    toleft = m - 1
    toright = n - m
    if toleft >= toright:
        return m - 1
    return m + 1




def rv(): return list(map(int, input().split()))
def rl(n): return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
print(solve())




n, m = map(int, input().split())
if n == 1:
    print(1)
elif n & 1:
    if (n + 1) // 2 <= m:
        print(m - 1)
    else:
        print(m + 1)
else:
    if n // 2 >= m:
        print(m + 1)
    else:
        print(m - 1)

n,m = list(map(int, input().split()))

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

n,m=[int(x) for x in input().split()]
if n==1:
    print(1)
elif n&1:
    if m>n//2:
        print(m-1)
    else:
        print(m+1)
else:
    if m<=n/2:
        print(m+1)
    else:
        print(m-1)
    


n,m=list(map(int,input().split(' ')))
if n==1:
    print(1)
else:
    if n%2==0:
        if m<=n//2:
            print(m+1)
        else:
            print(m-1)
    else:
        if m<=(n-1)//2:
            print(m+1)
        else:
            print(m-1)

n, m = map(int, input().split(' '))
if n == 1:
    print(1)
    return
r = n-m
l = m
print(m-1 if l > r else m+1)

n, m = (int(i) for i in input().split())
def solve():
    if n == 1:
        return 1
    # For n > 1, at least one of [a1, a2] must be valid

    a1 = m - 1
    a2 = m + 1
    if a1 < 1:
        return a2
    
    if a2 > n:
        return a1

    b1 = a1 # Numbers from 1 to a1 inclusive
    b2 = n - a2 + 1 # Numbers from a2 to n inclusive
    return a1 if b1 >= b2 else a2
    # "If there are multiple such values, print the minimum of them."

print(solve())


n,m=map(int,input().split())
if n==1: print(1)
elif n-m>m-1: print(m+1)
else: print(m-1) 

def bf(n,m, a):
    k=0
    for c in range(1, n+1):
        if abs(c-a)<abs(c-m):
            k+=1;
    return k
def solve(n, m):
    maxx = 0
    for i in range(1, n+1):
        maxx = max(maxx, bf(n, m, i))
    for i in range(1, n+1):
        if bf(n, m, i) == maxx:
            return(i)


def solve2(a, b):
    if a == 1 and b== 1:
        return 1
    if a == b:
        return a-1
    if b >= a:
        return max(a-(b-a)+1, 1)
    k = b-1
    l = b+1
    c1 = a-l+1
    if k >= c1:
        return k
    else:
        return l

a, b = list(map(int, input().split(' ')))
print(solve2(a, b))


n, m = map(int,input().split())
if n == 1:
    print(1)
    return
if m > n//2:
    print(m-1)
else:
    print(m+1)

#!/usr/bin/env python3
"""
Codeforces Round #316 (Div. 2)

Problem B. Simple Game

@author yamaton
@date 2015-08-13
"""

import itertools as it
import functools
import operator
import collections
import math
import sys


def solve(n, m):
    if n == 1:
        return 1
    if m <= n // 2:
        return m + 1
    else:
        return m - 1


def print_stderr(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    [n, m] = [int(i) for i in input().strip().split()]
    result = solve(n, m)
    print(result)


def __starting_point():
    main()
__starting_point()

n, m = list(map(int,input().split()))
if n != 1:
    if n % 2 == 0:
        if n // 2 >= m:
            print(m+1)
        else:
            print(m-1)
    else:
        n -= 1
        if n // 2 >= m:
            print(m+1)
        else:
            print(m-1)
else:
    print(1)


def main():
    n, m = [int(t) for t in input().split()]

    if n == 1:
        print(1)
    elif m <= n / 2.0:
        print(m + 1)
    else:
        print(m - 1)


def __starting_point():
    main()

__starting_point()

import sys

x = str(input()).split()
n = int(x[0])
m = int(x[1])

if n == 1:
    print(1)
    return
if n // 2 < m:
    print(m -1)
else:
    print(m+1)


n, m = (int(x) for x in input().split())
if m == 1:
	if n == 1:
		print(1)
	else:
		print(2)
	return
if m == n:
	print(n - 1)
	return
if m - 1 >= n - m:
	print(m - 1)
else:
	print(m + 1)


n, m = list(map(int, input().split()))
if n == 1 and m == 1:
    print(1)
else:    
    if n - m > m - 1:
        print(m + 1)
    else:
        print(m - 1)


import sys


fin = sys.stdin 
#fin = open ('in', 'r')

#fout = open ('out', 'w')

[n, m] = [int(x) for x in fin.readline().split()]



left = m - 1
right = n - m

if left >= right:
	print(max(m-1, 1))
else:
	print(min(m + 1, n))