RT
#include<iostream>
#include<cstdio>
using namespace std;
long long l,r,n,i,ans,a;
long long maxn(long long a,long long b)
{
if(a>b) return a;
else if(a<b) return b;
else return a;
}
int main()
{
cin>>n>>l>>r;
a=l/n;l=l-a*n;r=r-a*n;
if(r>n) cout<<n-1;
else
{
for(i=l;i<=r;i++)
{
ans=maxn(ans,i%n);
}
cout<<ans;
}
return 0;
}