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 #define inf 1000000000
12 #define maxn 300+10
13 #define maxm 500+100
14 #define ll long long
15 using namespace std;
16 inline ll read()
17 {
18 ll x=0,f=1;char ch=getchar();
19 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
20 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
21 return x*f;
22 }
23 int n,k,ans=0;
24 void dfs(int x)
25 {
26 if(x-k<2||((x&1)!=(k&1)))ans++;
27 else
28 {
29 int y=(x-k)>>1;dfs(y);y=x-y;dfs(y);
30 }
31 }
32 int main()
33 {
34 freopen("input.txt","r",stdin);
35 freopen("output.txt","w",stdout);
36 n=read();k=read();
37 dfs(n);
38 printf("%d\n",ans);
39 return 0;
40 }