using namespace std; int main(){ long long n,L,R; cin>>n>>L>>R; if((R-L+L%n)>=n) cout<<n-1; else cout<<R%n; return 0; }