#include <bits/stdc++.h>
using namespace std;
const int maxn = 64;
const long long one = 1;
long long n_cnt[maxn];
long long dfs(long long n, long long l, long long r, int o) {
  long long R = (one << (o + 1)) - 1;
  if (l == 1 && r == R) return n_cnt[o];
  long long M = R / 2 + 1;
  long long n2 = n / 2;
  int o2 = o - 1;
  if (r < M) return dfs(n2, l, r, o2);
  if (l > M) return dfs(n2, l - M, r - M, o2);
  long long lo = 0, ro = 0;
  if (l < M) lo = dfs(n2, l, M - 1, o2);
  if (r > M) ro = dfs(n2, 1, r - M, o2);
  return lo + ro + (n & 1);
}
int main() {
  long long n;
  long long l, r;
  cin >> n >> l >> r;
  if (n == 0) return !printf("0\n");
  int o = 63;
  while (!(n & (one << o))) o--;
  n_cnt[0] = (n & (one << o)) != 0;
  for (int i = 1; i <= o; i++) {
    n_cnt[i] = n_cnt[i - 1] * 2 + ((n & (one << (o - i))) != 0);
  }
  cout << dfs(n, l, r, o) << '\n';
  return 0;
}
