#include<stdio.h>

int main(){
    int n,m;
    
    if(scanf("%d %d",&n,&m)!=2);
       
    
    
    if ( n < 0 || m < 0){
        printf("Invalid input");
        return 0;
    }
    
    int a =n, b=m,temp;
    while (b!=0){
        temp =b;
        b=a&b;
        a=temp;
    }
    
    printf("%d",a);
    
    return 0;
}