import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
 
 //   System.out.println(calc(2,3));
 
    while(x != 0 && y != 0){
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    }
    //System.out.println(x + " " + y);
    if(x == 0){
        System.out.println(y);
    }else{
        System.out.println(x);
    }
   
    }
    
    public static int calc(int a, int b){
        return a % b;
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
 
 //   System.out.println(calc(2,3));
 
    while(x != 0 && y != 0){
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    }
    //System.out.println(x + " " + y);
    if(x == 0){
        System.out.println(y);
    }else{
        System.out.println(x);
    }
   
    }
    
    public static int calc(int a, int b){
        return a % b;
    }
} Main public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
 
 //   System.out.println(calc(2,3));
 
    while(x != 0 && y != 0){
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    }
    //System.out.println(x + " " + y);
    if(x == 0){
        System.out.println(y);
    }else{
        System.out.println(x);
    }
   
    } main {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
 
 //   System.out.println(calc(2,3));
 
    while(x != 0 && y != 0){
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    }
    //System.out.println(x + " " + y);
    if(x == 0){
        System.out.println(y);
    }else{
        System.out.println(x);
    }
   
    } 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 while(x != 0 && y != 0){
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    } x != 0 && y != 0 x != 0 x 0 y != 0 y 0 {
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    } if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        } x >= y x y {
            x = calc(x, y);
        } x = calc(x, y) x calc(x, y) calc x y {
            y = calc(y, x);
        } y = calc(y, x) y calc(y, x) calc y x if(x == 0){
        System.out.println(y);
    }else{
        System.out.println(x);
    } x == 0 x 0 {
        System.out.println(y);
    } System.out.println(y) System.out.println System.out System System.out y {
        System.out.println(x);
    } System.out.println(x) System.out.println System.out System System.out x String[] args args public static int calc(int a, int b){
        return a % b;
    } calc {
        return a % b;
    } return a % b; a % b a b int a a int b b public class Main {
    public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
 
 //   System.out.println(calc(2,3));
 
    while(x != 0 && y != 0){
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    }
    //System.out.println(x + " " + y);
    if(x == 0){
        System.out.println(y);
    }else{
        System.out.println(x);
    }
   
    }
    
    public static int calc(int a, int b){
        return a % b;
    }
} public class Main {
    public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
 
 //   System.out.println(calc(2,3));
 
    while(x != 0 && y != 0){
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    }
    //System.out.println(x + " " + y);
    if(x == 0){
        System.out.println(y);
    }else{
        System.out.println(x);
    }
   
    }
    
    public static int calc(int a, int b){
        return a % b;
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
 
 //   System.out.println(calc(2,3));
 
    while(x != 0 && y != 0){
        if(x >= y){
            x = calc(x, y);
        }else{
            y = calc(y, x);
        }
    }
    //System.out.println(x + " " + y);
    if(x == 0){
        System.out.println(y);
    }else{
        System.out.println(x);
    }
   
    }
    
    public static int calc(int a, int b){
        return a % b;
    }
}
