using System; using System.Linq; class No521{ static void Main(){ var count=Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray(); var ans=0; if(count[1]>=1&&count[0]>=count[1]&&count[0]!=1){ if(count[0]%2==1&&count[0]/2+1==count[1])ans=count[0]-1; else ans=count[0]-2; } Console.WriteLine(ans); } }