#include <stdio.h>

int fun(int a, int b) {
    if (a == 1 || b == 1) {
        return 1;
    } else if (a == b) {
        return a;
    }  else if (a > b) {  
        return (a % 2 == 0) ? fun(a / 2, b) : fun((a - 1) / 2, b);  
    } else {
        return (b % 2 == 0) ? fun(a, b / 2) : fun(a, (b - 1) / 2);  
    }  
    return 0;
}

int main() {
    int a, b;
    while (scanf("%d %d", &a, &b) != EOF) {
        printf("%d\n", fun(a,b));
    }
    return 0;
}