#include <bits/stdc++.h>
#define endl '\n';
using namespace std;
typedef long long int LL;
LL foo(LL i,LL l ,LL h, LL n){
LL mid=(l+h)/2;
if(mid==i) return (n&1);
if(i<mid) return foo(i,l,mid-1,n/2);
return foo(i,mid+1,h,n/2);
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);
//freopen("input.in","r",stdin);
LL n,l,r,res=0;
cin>>n>>l>>r;
if(n==0){
cout<<"0"<<endl;return 0;
}
LL h = (1ll<<(((int)(log2(n))) +1))-1;
for(LL i=l;i<=r;i++)
res+=foo(i-1,0,h,n);
cout<<res<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZW5kbCAnXG4nOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBpbnQgTEw7CgpMTCBmb28oTEwgaSxMTCAgbCAsTEwgaCwgTEwgbil7CglMTCBtaWQ9KGwraCkvMjsKCWlmKG1pZD09aSkgcmV0dXJuIChuJjEpOwoJaWYoaTxtaWQpIHJldHVybiBmb28oaSxsLG1pZC0xLG4vMik7CiAgICByZXR1cm4gZm9vKGksbWlkKzEsaCxuLzIpOwp9CgppbnQgbWFpbigpCnsKICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKDApOwoKICAgICAgLy9mcmVvcGVuKCJpbnB1dC5pbiIsInIiLHN0ZGluKTsKCiAgICAgIExMIG4sbCxyLHJlcz0wOwogICAgICBjaW4+Pm4+Pmw+PnI7IAogICAgICAgCiAgICAgIGlmKG49PTApewogICAgICAJY291dDw8IjAiPDxlbmRsO3JldHVybiAwOwogICAgICB9CgogICAgICBMTCBoID0gKDFsbDw8KCgoaW50KShsb2cyKG4pKSkgKzEpKS0xOwogICAgICAKICAgICAgZm9yKExMIGk9bDtpPD1yO2krKykKICAgICAgCXJlcys9Zm9vKGktMSwwLGgsbik7ICAgIAogICAgICBjb3V0PDxyZXM8PGVuZGw7CiAgCiAgcmV0dXJuIDA7Cn0=