/*
"IF U BELIEVE WHY NOT!!"
--Cristiano Ronaldo
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define M 1000000007
#define INF 1000000007
typedef pair<lli,lli> ll;
#define mem(a,x) memset(a,x,sizeof(a))
lli n,k,m;
lli dist[507][507];
lli path1[207][207];
vector<int> v2(1005,1);
vector<double> v;
lli x,y,c,z,t,q,u,d,a1,b;
struct edge
{
lli a,b,cost;
};
/*void djkstra(int x,vector<ll> v[])
{
mem(vis,0);
dist[x]=0;
s2.insert({0,x});
while(!s2.empty())
{
ll p=*s2.begin();
s2.erase(s2.begin());
x=p.second;
if(vis[x])
continue;
vis[x]=1;
for(int j=0;j<v[x].size();j++)
{
if(dist[v[x][j].second]>dist[x]+v[x][j].first)
{
dist[v[x][j].second]=dist[x]+v[x][j].first;
s2.insert({dist[v[x][j].second],v[x][j].second});
a[v[x][j].second]=x;
}
}
}
}*/
lli parent[100007];
lli find(lli a)
{
return a==parent[a]?a:parent[a]=find(parent[a]);
}
void dset(lli n)
{
for(int j=0;j<=n;j++)
parent[j]=j;
}
void unio(lli a,lli b,lli rank[])
{
if(rank[find(a)]>rank[find(b)])
parent[find(b)]=find(a);
else if(rank[find(b)]>rank[find(a)])
parent[find(a)]=find(b);
else
{
parent[find(a)]=find(b);
rank[find(b)]++;
}
}
bool check(lli a)
{
if((a1*a*m+b*(a-1)+d)>=x)
return true;
return false;
}
/*bool valid(int i,int x)
{
for(int j=1;j<x;j++)
{
if((abs(b[j-1]-i)==abs(j-x))||(i==b[j-1])||(j==x))
return false;
}
return true;
}*/
lli p[10007];
lli dp[301][301][301];
map<ll,ll> pat;
map<ll,lli> p2;
lli pr[200007],we[200007];
lli a[100005];
map<lli,lli> m4;
vector<int> v4;
int f=0;
lli tot=1;
lli vis[1001][1001];
lli p1;
lli s[10001];
lli n1;
lli solve(lli n,lli i,lli c)
{
//cout<<n<<" "<<i<<" "<<a[i]<<" "<<dp[n][i]<<endl;
if(i>n1)
return 0;
if(c==0&&n>0)
return 0;
if(c==0&&n==0)
return 1;
if(n<0)
return 0;
if(dp[n][i][c]!=-1)
return dp[n][i][c];
dp[n][i][c]=solve(n-i,i,c-1);
dp[n][i][c]+=solve(n,i+1,c);
return dp[n][i][c];
}
int main()
{
while(1)
{
string s="\0";
getline(cin,s);
if(s.size()==0)
return 0;
string d[3];
d[0]="\0";
d[1]="\0";
d[2]="\0";
int c=0;
for(int i=0;i<=300;i++)
{
for(int j=1;j<=300;j++)
{
for(int k=1;k<=300;k++)
dp[i][j][k]=-1;
}
}
for(int j=0;j<s.length();j++)
{
if(s[j]!=' ')
d[c]+=s[j];
else
c++;
}
int f;
stringstream ss(d[0]);
ss>>f;
n1=f;
lli d1=0;
for(int i=1;i<=f;i++)
d1+=solve(f,1,i);
for(int i=0;i<=300;i++)
{
for(int j=0;j<=300;j++)
dp[0][i][j]=1;
}
lli sum[f+1];
mem(sum,0);
sum[0]=1;
for(int i=1;i<=f;i++)
{
if(i==1)
sum[i]=dp[f][1][i];
else
sum[i]=sum[i-1]+dp[f][1][i];
}
if(c==0)
{
if(f!=0)
cout<<d1<<endl;
else
cout<<1<<endl;
}
else if(c==1)
{
int f1;
stringstream ss1(d[1]);
ss1>>f1;
if(f1>f)
f1=f;
cout<<sum[f1]<<endl;
}
else
{
int f1,f2;
stringstream ss1(d[1]);
ss1>>f1;
stringstream ss2(d[2]);
ss2>>f2;
if(f1>f)
cout<<0<<endl;
else
{
if(f2>f)
f2=f;
cout<<sum[f2]-sum[f1]+dp[f][1][f1]<<endl;
}
}
}
}
LyoKIklGIFUgQkVMSUVWRSBXSFkgTk9UISEiCiAgICAgICAgICAgICAgICAgICAgICAgLS1DcmlzdGlhbm8gUm9uYWxkbwoqLwojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBpbnQgbGxpOwojZGVmaW5lIE0gMTAwMDAwMDAwNwojZGVmaW5lIElORiAxMD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xpIG4xOwpsbGkgc29sdmUobGxpIG4sbGxpIGksbGxpIGMpCnsKLy9jb3V0PDxuPDwiICI8PGk8PCIgIjw8YVtpXTw8IiAiPDxkcFtuXVtpXTw8ZW5kbDsKaWYoaT5uMSkKcmV0dXJuIDA7CmlmKGM9PTAmJm4+MCkKcmV0dXJuIDA7CmlmKGM9PTAmJm49PTApCnJldHVybiAxOwppZihuPDApCnJldHVybiAwOwppZihkcFtuXVtpXVtjXSE9LTEpCnJldHVybiBkcFtuXVtpXVtjXTsKZHBbbl1baV1bY109c29sdmUobi1pLGksYy0xKTsKZHBbbl1baV1bY10rPXNvbHZlKG4saSsxLGMpOwpyZXR1cm4gZHBbbl1baV1bY107Cn0KaW50IG1haW4oKQp7CndoaWxlKDEpCnsKICAgIHN0cmluZyBzPSJcMCI7CiAgICBnZXRsaW5lKGNpbixzKTsKICAgIGlmKHMuc2l6ZSgpPT0wKQogICAgcmV0dXJuIDA7CiAgICBzdHJpbmcgZFszXTsKICAgIGRbMF09IlwwIjsKICAgIGRbMV09IlwwIjsKICAgIGRbMl09IlwwIjsKICAgIGludCBjPTA7CiAgICBmb3IoaW50IGk9MDtpPD0zMDA7aSsrKQogICAgewogICAgICAgIGZvcihpbnQgaj0xO2o8PTMwMDtqKyspCiAgICAgICAgewogICAgICAgIGZvcihpbnQgaz0xO2s8PTMwMDtrKyspCiAgICAgICAgZHBbaV1bal1ba109LTE7CiAgICAgICAgfQogICAgfQogICAgZm9yKGludCBqPTA7ajxzLmxlbmd0aCgpO2orKykKICAgIHsKICAgICAgICBpZihzW2pdIT0nICcpCiAgICAgICAgZFtjXSs9c1tqXTsKICAgICAgICBlbHNlCiAgICAgICAgYysrOwogICAgfQogICAgaW50IGY7CiAgICBzdHJpbmdzdHJlYW0gc3MoZFswXSk7CiAgICBzcz4+ZjsKICAgIG4xPWY7CiAgICBsbGkgZDE9MDsKICAgIGZvcihpbnQgaT0xO2k8PWY7aSsrKQogICAgZDErPXNvbHZlKGYsMSxpKTsKICAgIGZvcihpbnQgaT0wO2k8PTMwMDtpKyspCiAgICB7CiAgICAgICAgZm9yKGludCBqPTA7ajw9MzAwO2orKykKICAgICAgICBkcFswXVtpXVtqXT0xOwogICAgfQogICAgbGxpIHN1bVtmKzFdOwogICAgbWVtKHN1bSwwKTsKICAgIHN1bVswXT0xOwogICAgZm9yKGludCBpPTE7aTw9ZjtpKyspCiAgICB7CiAgICAgICAgaWYoaT09MSkKICAgICAgICBzdW1baV09ZHBbZl1bMV1baV07CiAgICAgICAgZWxzZQogICAgICAgIHN1bVtpXT1zdW1baS0xXStkcFtmXVsxXVtpXTsKICAgIH0KICAgIGlmKGM9PTApCiAgICB7CiAgICAgICAgaWYoZiE9MCkKICAgICAgICBjb3V0PDxkMTw8ZW5kbDsKICAgICAgICBlbHNlCiAgICAgICAgY291dDw8MTw8ZW5kbDsKICAgIH0KICAgIGVsc2UgaWYoYz09MSkKICAgIHsKICAgICAgICBpbnQgZjE7CiAgICAgICAgc3RyaW5nc3RyZWFtIHNzMShkWzFdKTsKICAgICAgICBzczE+PmYxOwogICAgICAgIGlmKGYxPmYpCiAgICAgICAgZjE9ZjsKICAgICAgICBjb3V0PDxzdW1bZjFdPDxlbmRsOwogICAgfQogICAgZWxzZQogICAgewogICAgICAgIGludCBmMSxmMjsKICAgICAgICBzdHJpbmdzdHJlYW0gc3MxKGRbMV0pOwogICAgICAgIHNzMT4+ZjE7CiAgICAgICAgCiAgICAgICAgc3RyaW5nc3RyZWFtIHNzMihkWzJdKTsKICAgICAgICBzczI+PmYyOwogICAgICAgIGlmKGYxPmYpCiAgICAgICAgY291dDw8MDw8ZW5kbDsKICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgIGlmKGYyPmYpCiAgICAgICAgZjI9ZjsKICAgICAgICBjb3V0PDxzdW1bZjJdLXN1bVtmMV0rZHBbZl1bMV1bZjFdPDxlbmRsOwogICAgICAgIH0KICAgIH0KfQp9