#include <vector>
#include <iostream>
using namespace std;

int main() {
    int x,y;
    while(cin>>x>>y){
        if(x<y) swap(x,y);//x>=y
        vector<int> x_path,y_path;
        x_path.push_back(x);
        y_path.push_back(y);
        while(x!=1&&y!=1){
            x/=2;
            x_path.push_back(x);
            y/=2;
            y_path.push_back(y);
        }
        while(x!=1){
           x/=2;
           x_path.push_back(x); 
        }
        while(y!=1){
            y/=2;
            y_path.push_back(y);
        }
        // for(int i=0;i<x_path.size();i++) cout<<x_path[i];
        // cout<<endl;
        // for(int j=0;j<y_path.size();j++) cout<<y_path[j];
        // cout<<endl;
        bool flag=false;
        for(int i=0;i<x_path.size();i++){
            for(int j=0;j<y_path.size();j++){
                if(x_path[i]==y_path[j]){
                    flag=true;
                    cout<<x_path[i]<<endl;
                    break;
                }
            }
            if(flag) break;
        }
    }
    return 0;
}
// 64 位输出请用 printf("%lld")