#include <bits/stdc++.h>
using namespace std;
int n,l,r;
int main(){
freopen("candy.in","r",stdin);
freopen("candy.out","w",stdout);
//ios::sync_with_stdio(0);
//cin.tie(0);
//cout.tie(0);
cin>>n>>l>>r;
int Max=-99999999;
int t;
for(int i=l;i<=r;i++){
t=i;
loop:if(t-n>=0){
t=t-n;
goto loop;
}
Max=max(Max,t);
}
cout<<Max;
//cout<<endl<<clock();
return 0;
}
洛谷自测100/yiw