#include "bits/stdc++.h"
using namespace std;
int main()
{
int n,l,r;
scanf("%d%d%d",&n,&l,&r);
if(r-l>=n) printf("%d",n-1);
else
{
int t=l%n;
int f=r%n;
if(f<t) printf("%d",n-1);
else printf("%d",f);
}
return 0;
}
/**************************************************************
Problem: 2401
User: admin
Language: C++
Result: Accepted
Time:55 ms
Memory:2076 kb
****************************************************************/