import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    while(true){
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    }
     sc.close();
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    while(true){
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    }
     sc.close();
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    while(true){
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    }
     sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    while(true){
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    }
     sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a=sc.nextInt(); a sc.nextInt() sc.nextInt sc int b=sc.nextInt(); b sc.nextInt() sc.nextInt sc while(true){
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    } true {
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    } if(a%b==0){
      System.out.println(b);
      break;
    } a%b==0 a%b a b 0 {
      System.out.println(b);
      break;
    } System.out.println(b) System.out.println System.out System System.out b break; a%=b a b if(b%a==0){
        System.out.println(a);
        break;
      } b%a==0 b%a b a 0 {
        System.out.println(a);
        break;
      } System.out.println(a) System.out.println System.out System System.out a break; b%=a b a sc.close() sc.close sc String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    while(true){
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    }
     sc.close();
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    while(true){
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    }
     sc.close();
  }
} Main
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    while(true){
    if(a%b==0){
      System.out.println(b);
      break;
    }
      a%=b;
      if(b%a==0){
        System.out.println(a);
        break;
      }
      b%=a;
    }
     sc.close();
  }
}
