#include <iostream>
#include<vector>
#include<string>
#include<math.h>
/***** S. M. Sabiul Hajjaj Sabit *****/
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
if(n-m==0)
{
cout<<0<<endl;
}
else if(m==0 || m==1)
{
cout<<1<<endl;
}
else if(m>n/2)
{
cout<<n%m<<endl;
}
else
{
cout<<m<<endl;
}
}
Add your comment