import java.util.*;

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

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