#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;
}

