///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
int x,y;
bitset<65>xx,yy;
int dp[66][2][2][2];
int solve(int pos,int is_big,int is_sml,int is_st)
{
    if(pos<0)
    {
        return 1;
    }
    int xbt=xx[pos];
    int ybt=yy[pos];
    int &ret=dp[pos][is_big][is_sml][is_st];
    if(ret!=(-1))return ret;
    ret=0;
    if(xbt==1)
    {
        if(ybt==0)
        {
           //x=1 , y=1
           if(is_sml)ret=ad(ret,solve(pos-1,is_big,is_sml,1));
           //x=0 ,y=0
           if(is_big)ret=ad(ret,solve(pos-1,is_big,is_sml,is_st));
           //x=0 , y = 1
           if(is_sml && is_big && is_st)ret=ad(ret,solve(pos-1,is_big,is_sml,is_st));
        }
        else if(ybt==1)
        {
           //x=1 , y=1
           ret=ad(ret,solve(pos-1,is_big,is_sml,1));
           //x=0 ,y=0
           if(is_big)ret=ad(ret,solve(pos-1,is_big,1,is_st));
           //x=0 , y = 1
           if(is_big && is_st)ret=ad(ret,solve(pos-1,is_big,is_sml,is_st));
        }
    }
    else if(xbt==0)
    {
         if(ybt==0)
        {
           //x=1 , y=1
           if(is_sml)ret=ad(ret,solve(pos-1,1,is_sml,1));
           //x=0 ,y=0
           ret=ad(ret,solve(pos-1,is_big,is_sml,is_st));
           //x=0 , y = 1
           if(is_sml && is_st)ret=ad(ret,solve(pos-1,is_big,is_sml,is_st));
        }
        else if(ybt==1)
        {
           //x=1 , y=1
           ret=ad(ret,solve(pos-1,1,is_sml,1));
           //x=0 ,y=0
           ret=ad(ret,solve(pos-1,is_big,1,is_st));
           //x=0 , y = 1
           if(is_st)ret=ad(ret,solve(pos-1,is_big,is_sml,is_st));
        }
    }
    return ret;
}
 main()

{
    fast
    memset(dp,-1,sizeof dp);
    cin>>x>>y;
    xx=x;
    yy=y;
    cout<<solve(64,0,0,0)<<endl;
    return 0;

}





Measured memory_bytes: 3592