#include<bits/stdc++.h>
using namespace std;
int main(){
// freopen("candy.in","r",stdin);
// freopen("candy.out","w",stdout);读写和输出文件
int n,L,R;
cin>>n>>L>>R;
int t=n-L%n;
if(L+t<=R){
cout<<n-1;
return 0;
//找规律后可发现如果L+t<=R,那么直接输出n-1就可以了
}
cout<<R%n;
//否则直接输出R%n
return 0;
}
//♂_The_LYH_25_♂