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 <image> 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 ≤ 109) — 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.
import java.io.*;
import java.math.*;
import java.util.*;
public class Q2 {
	static int INF = (int)(1e9);
	static long mod = (long)(1e9)+7;
	static long mod2 = 998244353;
	static long[] segtree;
	static char[] curans;
	static long ans;	
	static String S;
	static ArrayList<Integer>[] graph;
	static boolean[] vis;
	static int[] a;
	static int N;
	static long K;
	static long[] fact;
	static ArrayList<Long> pos;
	static ArrayList<Long> neg;
	static long[] max;
	static int[] dp;
	public static void main(String[] args) {  //Cash out
		/**/
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int T = 1;
		StringBuilder ret = new StringBuilder();
		while (T-- > 0) {
			int N = I.nextInt();
			int M = I.nextInt();
			
			int lo = M - 1;
			int hi = M + 1;
			
			if (hi > N) {
				hi = -1;
			}
			if (lo < 1) {
				lo = -1;
			}
			
			
			int lo_win = 0;
			int hi_win = 0;
			if (lo != -1) {
				lo_win = lo;
			}
			if (hi != -1) {
				hi_win = N - M;
			}
			
			int ans = 0;
			if (hi_win > lo_win) {
				ans = hi;
			}else {
				ans = lo; // Lower value is preferred when win profits are equal
			}
			
			if (ans == -1) { // (All options lead to losses)
				ans = 1; // Minimal value that loses
			}
			
			ret.append(ans + "\n");
			
		}
		O.pln(ret);
	}
	public static double[][] matrix_exp(double[][] a, long exp, long mod) {
		int R = a.length;
		int C = a[0].length;
		double[][] ans = new double[R][C];
		
		boolean mult_yet = false;
		
		while (exp > 0) {
			if (exp % 2 == 1) {
				if (!mult_yet) {
					mult_yet = true;
					for (int i = 0; i < R; i++) {
						for (int j = 0; j < C; j++) {
							ans[i][j] = a[i][j]; 
						}
					}
				}else {
					double[][] new_ans = mult(ans, a, mod);
					for (int i = 0; i < R; i++) {
						for (int j = 0; j < C; j++) {
							ans[i][j] = new_ans[i][j]; 
						}
					}
				}
			}
			
			double[][] new_a = mult(a, a, mod); // a = a^2 (binary exponentiation on matrices)
			for (int i = 0; i < R; i++) {
				for (int j = 0; j < C; j++) {
					a[i][j] = new_a[i][j]; 
				}
			}
			exp /= 2;
		}
		
		return ans;
	}
	public static double[][] mult(double[][] a, double[][] b, long mod) {
		int r1 = a.length;
		int c1 = a[0].length;
		int r2 = b.length;
		int c2 = b[0].length;
		//Requires: c1 = r2
		
		double[][] ans = new double[r1][c2];
		for (int r = 0; r < r1; r++) {
			for (int c = 0; c < c2; c++) {
				//Dot product of (a[r])^T and b[c] (as vectors in R^n (n = c1 = r2))
				double[] col_vector = new double[r2];
				double[] row_vector = new double[c1];
				
				for (int i = 0; i < r2; i++) {
					col_vector[i] = b[i][c];
				}
				for (int i = 0; i < c1; i++) {
					row_vector[i] = a[r][i]; 
				}
				
				ans[r][c] = dot_product(row_vector, col_vector, mod);
			}
		}
		return ans;
	}
	
	public static double dot_product(double[] a, double[] b, long mod) {
		double ans = 0;
		int N = a.length; //Requires: a and b are both vectors in R^n
		for (int i = 0; i < N; i++) {
			ans += a[i] * b[i];
		}
		return ans;
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long abs(int x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}
