import java.util.*;

class Main{
  public static void main(String args[]){
  	Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    class Inner{
      int inner(int x,int y){
        if(y == 0){
          return x;
        }else{
          return inner(y,x%y);
        }
      }
    }
    Inner in = new Inner();
    System.out.println(in.inner(x,y));
  }
}
 import java.util.*; util.* java class Main{
  public static void main(String args[]){
  	Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    class Inner{
      int inner(int x,int y){
        if(y == 0){
          return x;
        }else{
          return inner(y,x%y);
        }
      }
    }
    Inner in = new Inner();
    System.out.println(in.inner(x,y));
  }
} Main public static void main(String args[]){
  	Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    class Inner{
      int inner(int x,int y){
        if(y == 0){
          return x;
        }else{
          return inner(y,x%y);
        }
      }
    }
    Inner in = new Inner();
    System.out.println(in.inner(x,y));
  } main {
  	Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    class Inner{
      int inner(int x,int y){
        if(y == 0){
          return x;
        }else{
          return inner(y,x%y);
        }
      }
    }
    Inner in = new Inner();
    System.out.println(in.inner(x,y));
  } 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 Inner in = new Inner(); in new Inner() System.out.println(in.inner(x,y)) System.out.println System.out System System.out in.inner(x,y) in.inner in x y String args[] args
import java.util.*;

class Main{
  public static void main(String args[]){
  	Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    class Inner{
      int inner(int x,int y){
        if(y == 0){
          return x;
        }else{
          return inner(y,x%y);
        }
      }
    }
    Inner in = new Inner();
    System.out.println(in.inner(x,y));
  }
}

