1 #include<cstdio>
2 #include<cstdlib>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #include<iostream>
7 #include<vector>
8 #include<map>
9 #include<set>
10 #include<queue>
11 #include<string>
12 #define inf 1000000000
13 #define maxn 1000000+1000
14 #define maxm 500+100
15 #define eps 1e-10
16 #define ll long long
17 #define pa pair<int,int>
18 #define mod 1000000000
19 using namespace std;
20 inline int read()
21 {
22 int x=0,f=1;char ch=getchar();
23 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
24 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
25 return x*f;
26 }
27 int n;
28 ll f[maxn];
29 int main()
30 {
31 freopen("input.txt","r",stdin);
32 freopen("output.txt","w",stdout);
33 n=read();
34 f[0]=1;
35 for(int i=0;i<=30;i++)
36 {
37 int x=1<<i;
38 if(x>n)break;
39 for(int j=x;j<=n;j++)f[j]+=f[j-x],f[j]%=mod;
40 }
41 printf("%lld\n",f[n]);
42 return 0;
43 }