/*Author: Satyajeet Singh, Delhi Technological University*/
    import java.io.*;
    import java.util.*;
    import java.text.*; 
    import java.lang.*;
    import java.math.*;
 
public class Main{
/*********************************************Constants******************************************/
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));        
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static long mod=(long)1e9+7;
    static long mod1=998244353;
    static boolean sieve[];
    static ArrayList<Integer> primes;
    static ArrayList<Long> factorial;
    static HashSet<Pair> graph[];
    static boolean oj = System.getProperty("ONLINE_JUDGE") != null;
/****************************************Solutions Begins***************************************/
    static ArrayList<Long> list,ls;
    static long dp[][][][][][];
    static long dfs(int i,int x,int y,int f,int e,int f2){
        if(i==list.size()){

            if(f<=1&&e==0&&f2<=1){
                return 1;
            }
            else{
                return 0;
            }
        }
        if(dp[i][x][y][f][e][f2]!=-1){
            return dp[i][x][y][f][e][f2];
        }
        long ans=0;
        //0,0
        int aa=0;
        if(ls.get(i)==1)aa=2;
        else aa=f2;

        if(list.get(i)==1){
            ans=(ans+dfs(i+1,0,0,0,e,aa))%mod;
        }
        else{
            ans=(ans+dfs(i+1,0,0,f,e,aa))%mod;
        }
        //1,0
        if(list.get(i)==1){
            ans=(ans+dfs(i+1,1,0,f,1,aa))%mod;
        }
        else{
            ans=(ans+dfs(i+1,1,0,2,1,aa))%mod;
        }
        //1,1
        if(ls.get(i)==1)aa=f2;
        else aa=0;
        if(list.get(i)==1){
            ans=(ans+dfs(i+1,1,1,f,0,aa))%mod;
        }
        else{
            ans=(ans+dfs(i+1,1,1,2,0,aa))%mod;
        }
        dp[i][x][y][f][e][f2]=ans;
        return ans;
    }
    static long fn(long a,long b){
        list=new ArrayList<>();
        long k=a;
        while(k!=0){
            list.add(k%2);
            k/=2;
        }
        ls=new ArrayList<>();
        k=b;
        while(k!=0){
            ls.add(k%2);
            k/=2;
        }
        while(ls.size()!=list.size())ls.add(0l);
       // debug(list);

        dp=new long[list.size()][2][2][3][2][3];
        for(long arr[][][][][]:dp)
            for(long ar1[][][][]:arr)
                for(long ar2[][][]:ar1)
                    for(long aa[][]:ar2)
                        for(long hh[]:aa)
                            Arrays.fill(hh,-1);
        long ans=dfs(0,0,0,1,0,1);
        return ans;
    }
    public static void main (String[] args) throws Exception {
        String st[]=br.readLine().split(" ");
        long a=pl(st[0]);
        long b=pl(st[1]);
        // debug(b,a);
       // debug(fn(4));
        //debug(fn(b),fn(a-1));
        long ans=fn(b,a);
        out.println(ans);
    
/****************************************Solutions Ends**************************************************/
        out.flush();
        out.close();
    }
/****************************************Template Begins************************************************/
    static String[] nl() throws Exception{
        return br.readLine().split(" ");
    }
    static String[] nls() throws Exception{
        return br.readLine().split("");
    }
    static int pi(String str) {
        return Integer.parseInt(str);
    }
    static long pl(String str){
        return Long.parseLong(str);
    }
    static double pd(String str){
        return Double.parseDouble(str);
    }
/***************************************Precision Printing**********************************************/
    static void printPrecision(double d){
        DecimalFormat ft = new DecimalFormat("0.00000000000000000"); 
        out.println(ft.format(d));
    }
/**************************************Bit Manipulation**************************************************/
    static void printMask(long mask){
        System.out.println(Long.toBinaryString(mask));
    }
    static int countBit(int mask){
        int ans=0;
        while(mask!=0){
            if(mask%2==1){
                ans++;
            }
            mask/=2;
        }
        return ans;
    }
/******************************************Graph*********************************************************/
    static void Makegraph(int n){
        graph=new HashSet[n];
        for(int i=0;i<n;i++){
            graph[i]=new HashSet<>();
        }
    }
    static void addEdge(int a,int b,int c){
        graph[a].add(new Pair(b,c));
    }    
/*********************************************PAIR********************************************************/
    static class PairComp implements Comparator<Pair>{
        public int compare(Pair p1,Pair p2){
            if(p1.u!=p2.u){
                return p1.u-p2.u;
            }
            else{
                return p1.u-p2.u;
            }
        }
    }
    static class Pair implements Comparable<Pair> {
        int u;
        int v;
        int index=-1;
        public Pair(int u, int v) {
            this.u = u;
            this.v = v;
        }
 
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
 
        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }
 
        public int compareTo(Pair other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
 
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
/******************************************Long Pair*************************************************/
    static class PairCompL implements Comparator<Pairl>{
        public int compare(Pairl p1,Pairl p2){
            long aa=p2.v-p1.v;
            if(aa<0){
                return -1;
            }
            else if(aa>0){
                return 1;
            }
            else{
                return 0;
            }
        }
    }
    static class Pairl implements Comparable<Pairl> {
            long u;
            long v;
            int index=-1;
            public Pairl(long u, long v) {
                this.u = u;
                this.v = v;
            }
    
            public int hashCode() {
                int hu = (int) (u ^ (u >>> 32));
                int hv = (int) (v ^ (v >>> 32));
                return 31 * hu + hv;
            }
    
            public boolean equals(Object o) {
                Pair other = (Pair) o;
                return u == other.u && v == other.v;
            }
    
            public int compareTo(Pairl other) {
                if(index!=other.index)
                    return Long.compare(index, other.index);
                return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
            }
    
            public String toString() {
                return "[u=" + u + ", v=" + v + "]";
            }
        }
/*****************************************DEBUG***********************************************************/
    public static void debug(Object... o) {
        if(!oj)
        System.out.println(Arrays.deepToString(o));
    }
/************************************MODULAR EXPONENTIATION***********************************************/
    static long modulo(long a,long b,long c) {
        long x=1;
        long y=a;
        while(b > 0){
            if(b%2 == 1){
                x=(x*y)%c;
            }
            y = (y*y)%c; // squaring the base
            b /= 2;
        }
        return  x%c;
    }
/********************************************GCD**********************************************************/
    static long gcd(long x, long y)
    {
        if(x==0)
            return y;
        if(y==0)
            return x;
        long r=0, a, b;
        a = (x > y) ? x : y; // a is greater number
        b = (x < y) ? x : y; // b is smaller number
        r = b;
        while(a % b != 0)
        {
            r = a % b;
            a = b;
            b = r;
        }
        return r;
    }
/******************************************SIEVE**********************************************************/
    static void sieveMake(int n){
        sieve=new boolean[n];
        Arrays.fill(sieve,true);
        sieve[0]=false;
        sieve[1]=false;
        for(int i=2;i*i<n;i++){
            if(sieve[i]){
                for(int j=i*i;j<n;j+=i){
                    sieve[j]=false;
                }
            }
        }
        primes=new ArrayList<Integer>();
        for(int i=0;i<n;i++){
            if(sieve[i]){
                primes.add(i);
            }
        }        
    }
/********************************************End***********************************************************/
}

Measured memory_bytes: 21844