#include <iostream> #include <cstdio> #include <algorithm> using namespace std; long long s,n,r,l,i,j,ans = -1e9; int main() { //freopen("candy.in","r",stdin); //freopen("candy.out","w",stdout); cin>>n>>l>>r; for(i = l;i <= r;i++) { ans = max(ans,(i % n)); if(ans == n - 1)break; } cout<<ans; //fclose(stdin); //fclose(stdout); return 0; }