#include <cstdio>
#include <algorithm>
static const int K = 41;
long long n, ans;
int l, r, m;
long long f[K][K][2][2];
int main() {
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
scanf("%I64d%d%d", &n, &l, &r);
m = 1;
while ((1LL << m) <= n)
m++;
f[0][l][0][0] = f[0][l][0][1] = 1;
for (int i = 1; i <= m; i++) {
for (int j = l; j <= r; j++) {
if (n & (1LL << (i - 1))) {
f[i][1][0][0] += f[i - 1][j][0][1] + f[i - 1][j][1][1];
f[i][1][0][1] += f[i - 1][j][0][0];
f[i][1][1][0] += 0;
f[i][1][1][1] += f[i - 1][j][1][0];
} else {
f[i][1][0][0] += f[i - 1][j][0][1];
f[i][1][0][1] += 0;
f[i][1][1][0] += f[i - 1][j][1][1];
f[i][1][1][1] += f[i - 1][j][0][0] + f[i - 1][j][1][0];
}
}
for (int j = 2; j <= i; j++) {
if (n & (1LL << (i - 1))) {
f[i][j][0][0] += f[i - 1][j - 1][0][0] + f[i - 1][j - 1][1][0];
f[i][j][0][1] += f[i - 1][j - 1][0][1];
f[i][j][1][0] += 0;
f[i][j][1][1] += f[i - 1][j - 1][1][1];
} else {
f[i][j][0][0] += f[i - 1][j - 1][0][0];
f[i][j][0][1] += 0;
f[i][j][1][0] += f[i - 1][j - 1][1][0];
f[i][j][1][1] += f[i - 1][j - 1][0][1] + f[i - 1][j - 1][1][1];
}
}
}
for (int i = 1; i < m; i++)
for (int j = l; j <= r; j++)
ans += f[i][j][0][1] + f[i][j][1][1];
for (int i = l; i <= r; i++)
ans += f[m][i][0][1];
printf("%I64d", ans);
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnN0YXRpYyBjb25zdCBpbnQgSyA9IDQxOwoKbG9uZyBsb25nIG4sIGFuczsKaW50IGwsIHIsIG07CmxvbmcgbG9uZyBmW0tdW0tdWzJdWzJdOwoKaW50IG1haW4oKSB7CiAgICBmcmVvcGVuKCJpbnB1dC50eHQiLCAicnQiLCBzdGRpbik7CiAgICBmcmVvcGVuKCJvdXRwdXQudHh0IiwgInd0Iiwgc3Rkb3V0KTsKCiAgICBzY2FuZigiJUk2NGQlZCVkIiwgJm4sICZsLCAmcik7CgogICAgbSA9IDE7CgogICAgd2hpbGUgKCgxTEwgPDwgbSkgPD0gbikKICAgICAgICBtKys7CgogICAgZlswXVtsXVswXVswXSA9IGZbMF1bbF1bMF1bMV0gPSAxOwoKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG07IGkrKykgewogICAgICAgIGZvciAoaW50IGogPSBsOyBqIDw9IHI7IGorKykgewogICAgICAgICAgICBpZiAobiAmICgxTEwgPDwgKGkgLSAxKSkpIHsKICAgICAgICAgICAgICAgIGZbaV1bMV1bMF1bMF0gKz0gZltpIC0gMV1bal1bMF1bMV0gKyBmW2kgLSAxXVtqXVsxXVsxXTsKICAgICAgICAgICAgICAgIGZbaV1bMV1bMF1bMV0gKz0gZltpIC0gMV1bal1bMF1bMF07CiAgICAgICAgICAgICAgICBmW2ldWzFdWzFdWzBdICs9IDA7CiAgICAgICAgICAgICAgICBmW2ldWzFdWzFdWzFdICs9IGZbaSAtIDFdW2pdWzFdWzBdOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZltpXVsxXVswXVswXSArPSBmW2kgLSAxXVtqXVswXVsxXTsKICAgICAgICAgICAgICAgIGZbaV1bMV1bMF1bMV0gKz0gMDsKICAgICAgICAgICAgICAgIGZbaV1bMV1bMV1bMF0gKz0gZltpIC0gMV1bal1bMV1bMV07CiAgICAgICAgICAgICAgICBmW2ldWzFdWzFdWzFdICs9IGZbaSAtIDFdW2pdWzBdWzBdICsgZltpIC0gMV1bal1bMV1bMF07CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGZvciAoaW50IGogPSAyOyBqIDw9IGk7IGorKykgewogICAgICAgICAgICBpZiAobiAmICgxTEwgPDwgKGkgLSAxKSkpIHsKICAgICAgICAgICAgICAgIGZbaV1bal1bMF1bMF0gKz0gZltpIC0gMV1baiAtIDFdWzBdWzBdICsgZltpIC0gMV1baiAtIDFdWzFdWzBdOwogICAgICAgICAgICAgICAgZltpXVtqXVswXVsxXSArPSBmW2kgLSAxXVtqIC0gMV1bMF1bMV07CiAgICAgICAgICAgICAgICBmW2ldW2pdWzFdWzBdICs9IDA7CiAgICAgICAgICAgICAgICBmW2ldW2pdWzFdWzFdICs9IGZbaSAtIDFdW2ogLSAxXVsxXVsxXTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGZbaV1bal1bMF1bMF0gKz0gZltpIC0gMV1baiAtIDFdWzBdWzBdOwogICAgICAgICAgICAgICAgZltpXVtqXVswXVsxXSArPSAwOwogICAgICAgICAgICAgICAgZltpXVtqXVsxXVswXSArPSBmW2kgLSAxXVtqIC0gMV1bMV1bMF07CiAgICAgICAgICAgICAgICBmW2ldW2pdWzFdWzFdICs9IGZbaSAtIDFdW2ogLSAxXVswXVsxXSArIGZbaSAtIDFdW2ogLSAxXVsxXVsxXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBmb3IgKGludCBpID0gMTsgaSA8IG07IGkrKykKICAgICAgICBmb3IgKGludCBqID0gbDsgaiA8PSByOyBqKyspCiAgICAgICAgICAgIGFucyArPSBmW2ldW2pdWzBdWzFdICsgZltpXVtqXVsxXVsxXTsKCiAgICBmb3IgKGludCBpID0gbDsgaSA8PSByOyBpKyspCiAgICAgICAgYW5zICs9IGZbbV1baV1bMF1bMV07CgogICAgcHJpbnRmKCIlSTY0ZCIsIGFucyk7CgogICAgcmV0dXJuIDA7Cn0K