#include<bits/stdc++.h>
using namespace std;
int n,l,r;
int maxx;
int main(){
scanf("%d%d%d",&n,&l,&r);
for(int i=1;maxx<r;i++) maxx+=n;
if(maxx>r){
maxx-=n;
if(maxx>=l) return printf("%d",n-1)&0;
else return printf("%d",r-maxx)&0;
}
if(maxx==r){
printf("%d",n-1);
return 0;
}
return 0;
}