import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans = 0;

    while(true){
      if(x<y){
        int change = x;
        x = y;
        y = change;
      }

      if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      }

    }
  }
}
 import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans = 0;

    while(true){
      if(x<y){
        int change = x;
        x = y;
        y = change;
      }

      if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      }

    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans = 0;

    while(true){
      if(x<y){
        int change = x;
        x = y;
        y = change;
      }

      if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      }

    }
  } main {
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans = 0;

    while(true){
      if(x<y){
        int change = x;
        x = y;
        y = change;
      }

      if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      }

    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc int ans = 0; ans 0 while(true){
      if(x<y){
        int change = x;
        x = y;
        y = change;
      }

      if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      }

    } true {
      if(x<y){
        int change = x;
        x = y;
        y = change;
      }

      if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      }

    } if(x<y){
        int change = x;
        x = y;
        y = change;
      } x<y x y {
        int change = x;
        x = y;
        y = change;
      } int change = x; change x x = y x y y = change y change if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      } x%y > 0 x%y x y 0 {
        int change = x%y;
        x = y;
        y = change;
      } int change = x%y; change x%y x y x = y x y y = change y change {
        ans = y;
        System.out.println(ans);
        break;
      } ans = y ans y System.out.println(ans) System.out.println System.out System System.out ans break; String[] args args
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans = 0;

    while(true){
      if(x<y){
        int change = x;
        x = y;
        y = change;
      }

      if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      }

    }
  }
}

