#include <bits/stdc++.h>
#define endl '\n';
using namespace std;
typedef long long int LL;
int LOG2(LL n){
int c=0;
while(n>1){
c++; n>>=1;
}
return c;
}
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+CiNkZWZpbmUgZW5kbCAnXG4nOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBpbnQgTEw7CgppbnQgTE9HMihMTCBuKXsKICBpbnQgYz0wOwogIHdoaWxlKG4+MSl7CiAgICBjKys7IG4+Pj0xOwogIH0KICByZXR1cm4gYzsKfQoKTEwgZm9vKExMIGksTEwgIGwgLExMIGgsIExMIG4pewoJTEwgbWlkPShsK2gpLzI7CglpZihtaWQ9PWkpIHJldHVybiAobiYxKTsKCWlmKGk8bWlkKSByZXR1cm4gZm9vKGksbCxtaWQtMSxuLzIpOwogICAgcmV0dXJuIGZvbyhpLG1pZCsxLGgsbi8yKTsKfQoKaW50IG1haW4oKQp7CiAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7Y2luLnRpZSgwKTsKCiAgICAgIC8vZnJlb3BlbigiaW5wdXQuaW4iLCJyIixzdGRpbik7CgogICAgICBMTCBuLGwscixyZXM9MDsKICAgICAgY2luPj5uPj5sPj5yOyAKICAgICAgIAogICAgICBpZihuPT0wKXsKICAgICAgCWNvdXQ8PCIwIjw8ZW5kbDtyZXR1cm4gMDsKICAgICAgfQoKICAgICAgTEwgaCA9ICgxbGw8PCgoKGludCkoTE9HMihuKSkpICsxKSktMTsKICAgICAgCiAgICAgIGZvcihMTCBpPWw7aTw9cjtpKyspCiAgICAgIAlyZXMrPWZvbyhpLTEsMCxoLG4pOyAgICAKICAgICAgY291dDw8cmVzPDxlbmRsOwogIAogIHJldHVybiAwOwp9Cgo=