# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<LL>>g;
vector<edge>edges;
vector<Pll>v;
map<Pll, Pll>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000],dp[60][2][2];
string str, ss;
bool f[200][200];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL lm, rm;
int main() {
	//dp[i][L][R]
	//L=0
	cin >> n >> m;
	rep(i, 63) {
		if ((1LL << i) <= n)lm = i;
	}
	rep(i, 63) {
		if ((1LL << i) <= m)rm = i;
	}
	if (lm == rm) {
		dp[rm][0][0] = 1;
	}
	else {
		dp[rm][1][0] = 1;
	}
	for (LL i = rm - 1; i >= 0; i--) {
		if (i > lm) {
			dp[i][1][1] += 1;
		}
		if (i == lm) {
			dp[i][0][1] += 1;
		}
		
		if ((bool)((1LL << i)&n)&(bool)((1LL << i)&m)) {
			dp[i][1][1] += dp[i + 1][1][1] * 3;
			dp[i][0][0] += dp[i + 1][0][0];
			dp[i][1][0] += dp[i + 1][1][0] * 2;
			dp[i][1][1] += dp[i + 1][1][0];
			dp[i][0][1] += dp[i + 1][0][1];
		}
		else if ((bool)((1LL << i)&n)&(!(bool)((1LL << i)&m))) {
			dp[i][1][1] += dp[i + 1][1][1] * 3;
			dp[i][1][0] += dp[i + 1][1][0];
			dp[i][0][1] += dp[i + 1][0][1];
		}
		else if ((!(bool)((1LL << i)&n)) & (bool)((1LL << i)&m)) {
			dp[i][1][1] += dp[i + 1][1][1] * 3;
			dp[i][0][0] += dp[i + 1][0][0];
			dp[i][0][1] += dp[i + 1][0][0];
			dp[i][1][0] += dp[i + 1][0][0];
			dp[i][1][0] += dp[i + 1][1][0] * 2;
			dp[i][1][1] += dp[i + 1][1][0];
			dp[i][0][1] += dp[i + 1][0][1] * 2;
			dp[i][1][1] += dp[i + 1][0][1];
		}
		else if ((!(bool)((1LL << i)&n)) &(!(bool)((1LL << i)&m))) {
			dp[i][1][1] += dp[i + 1][1][1] * 3;
			dp[i][0][0] += dp[i + 1][0][0];
			dp[i][1][0] += dp[i + 1][1][0];
			dp[i][0][1] += dp[i + 1][0][1] * 2;
			dp[i][1][1] += dp[i + 1][0][1];
		}
		else {
			cout << i << endl;
		}
		rep(j, 2)rep(k, 2)
			dp[i][j][k] %= MOD;
	}
	rep(j, 2)rep(k, 2)
		ans += dp[0][j][k];
	cout << ans%MOD << endl;
	return 0;
}


Measured memory_bytes: 256