570_B. Simple Game_10306
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.util.*;
public class ndz {

 public static void main(String[] args) {
   Scanner no=new Scanner(System.in);
   //1234567
   //12345678
   int n=no.nextInt();
   int m=no.nextInt();
   if(n%2==1){
     if(n==1){
       System.out.println(1);
     }
    else{
     int r=(n+1)/2;
     if(m>r){
       System.out.println(m-1);
     }
     else if(m<r){
       System.out.println(m+1);
     }
     else{
       System.out.println(r-1);
     }
    }
   }
   else{
     int r=n/2;
     if(m>r){
       System.out.println(m-1);
     }
     else if(m<r){
       System.out.println(m+1);
     }
     else{
       System.out.println(r+1);
     }
   }
  }

}
3 1
 4 3
 692501734 346250868
 616075979 207073797
 296647497 148323750
 401241775 170032078
 4 2
 541904957 459371829
 5 3
 3 2
 971573366 216791157
 5 1
 12412523 125123
 619189108 309594555
 746085224 373042613
 404354904 202177453
 100 51
 189520699 94760350
 2 2
 51 1
 81813292 40906647
 186407570 160453970
 262833325 131416663
 2 1
 1000000000 1000000000
 925779379 720443954
 7 4
 355447788 85890184
 570281992 291648263
 4 1
 54645723 432423
 5 4
 477667530 238833766
 1000000000 100000000
 726315905 363157953
 907335939 453667970
 511481701 255740851
 756739161 125332525
 3 3
 496110970 201868357
 5 2
 1000000000 500000000
 5 5
 20 13
 140613583 93171580
 1 1
 1000000000 1
 4 4
 10 5
 100 49
 1000000000 123124
 100 50
 7 3
 710945175 173165570
 1199670843 346250868
 547524057 207073797
 225228194 148323750
 401241775 174205084
 9 2
 5 6
 1814941421 216791157
 3 0
 11760588 125123
 619189108 92758980
 746085224 443618423
 769610844 202177453
 100 64
 189520699 83119639
 106645219 40906647
 357489581 160453970
 262833325 14414132
 570281992 262810956
 8 1
 54645723 225950
 477667530 342885563
 1000000000 100000001
 511481701 341396901
 1420256563 125332525
 496110970 45749885
 1000000000 838634356
 140613583 29244115
 101 49
 1000000000 137544
 710945175 206472837
 1199670843 347959889
 444260482 148323750
 401241775 98325353
 1814941421 409356121
 619189108 144265627
 1446809216 443618423
 262833325 24738418
 570281992 189468212
 927549905 342885563
 511481701 37934387
 1420256563 102876050
 496110970 62290453
 1000000000 3
 101 72
 1000000000 204824
 710945175 197643061
 315519838 207073797
 401241775 11308010
 3090540 70412
 619189108 223276879
 1446809216 733678520
 382502558 202177453
 210683652 60508467
 262833325 25062611
 9955122 137999
 927549905 332144609
 51 2
 2 0
 7 6
 6 1
 6 2
 5 0
 1000000000 2
 10 4
 7 0
 4 0
 657852912 207073797
 9 1
 3090540 125123
 1320661084 202177453
 101 64
 259370142 83119639
 51 0
 210683652 40906647
 8 0
 9955122 225950
 10 1
 1000000010 100000001
 6 0
 10 2
 8 3
 757410813 148323750
 15 2
 1863031294 409356121
 111 64
 197477460 83119639
 88 0
 443625088 189468212
 16 0
 18 1

2
 2
 346250867
 207073798
 148323749
 170032079
 3
 459371828
 2
 1
 216791158
 2
 125124
 309594554
 373042612
 202177452
 50
 94760349
 1
 2
 40906646
 160453969
 131416662
 2
 999999999
 720443953
 3
 85890185
 291648262
 2
 432424
 3
 238833765
 100000001
 363157952
 453667969
 255740850
 125332526
 2
 201868358
 3
 500000001
 4
 12
 93171579
 1
 2
 3
 6
 50
 123125
 51
 4
 173165571
 346250869
 207073798
 148323749
 174205085
 3
 5
 216791158
 1
 125124
 92758981
 443618422
 202177454
 63
 83119640
 40906648
 160453971
 14414133
 262810957
 2
 225951
 342885562
 100000002
 341396900
 125332526
 45749886
 838634355
 29244116
 50
 137545
 206472838
 347959890
 148323751
 98325354
 409356122
 144265628
 443618424
 24738419
 189468213
 342885564
 37934388
 102876051
 62290454
 4
 71
 204825
 197643062
 207073796
 11308011
 70413
 223276880
 733678519
 202177452
 60508468
 25062612
 138000
 332144610
 3
 1
 5
 2
 3
 1
 3
 5
 1
 1
 207073798
 2
 125124
 202177454
 63
 83119640
 1
 40906648
 1
 225951
 2
 100000002
 1
 3
 4
 148323751
 3
 409356122
 63
 83119640
 1
 189468213
 1
 2
