import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static void gcd(int a, int b){
            int x = Math.max(a,b);
            int y = Math.min(a,b);
            int t = 0;
            while (y>0){
                t = x;
                x = y;
                y = t%y;
            }
            System.out.println(x);
    }
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int ans = 0;
        gcd(a,b);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    static void gcd(int a, int b){
            int x = Math.max(a,b);
            int y = Math.min(a,b);
            int t = 0;
            while (y>0){
                t = x;
                x = y;
                y = t%y;
            }
            System.out.println(x);
    }
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int ans = 0;
        gcd(a,b);
    }
} Main static void gcd(int a, int b){
            int x = Math.max(a,b);
            int y = Math.min(a,b);
            int t = 0;
            while (y>0){
                t = x;
                x = y;
                y = t%y;
            }
            System.out.println(x);
    } gcd {
            int x = Math.max(a,b);
            int y = Math.min(a,b);
            int t = 0;
            while (y>0){
                t = x;
                x = y;
                y = t%y;
            }
            System.out.println(x);
    } int x = Math.max(a,b); x Math.max(a,b) Math.max Math a b int y = Math.min(a,b); y Math.min(a,b) Math.min Math a b int t = 0; t 0 while (y>0){
                t = x;
                x = y;
                y = t%y;
            } y>0 y 0 {
                t = x;
                x = y;
                y = t%y;
            } t = x t x x = y x y y = t%y y t%y t y System.out.println(x) System.out.println System.out System System.out x int a a int b b public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int ans = 0;
        gcd(a,b);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int ans = 0;
        gcd(a,b);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] line = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int a = Integer.parseInt(line[0]); a Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int b = Integer.parseInt(line[1]); b Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 int ans = 0; ans 0 gcd(a,b) gcd a b String[] args args public class Main {
    static void gcd(int a, int b){
            int x = Math.max(a,b);
            int y = Math.min(a,b);
            int t = 0;
            while (y>0){
                t = x;
                x = y;
                y = t%y;
            }
            System.out.println(x);
    }
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int ans = 0;
        gcd(a,b);
    }
} public class Main {
    static void gcd(int a, int b){
            int x = Math.max(a,b);
            int y = Math.min(a,b);
            int t = 0;
            while (y>0){
                t = x;
                x = y;
                y = t%y;
            }
            System.out.println(x);
    }
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int ans = 0;
        gcd(a,b);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static void gcd(int a, int b){
            int x = Math.max(a,b);
            int y = Math.min(a,b);
            int t = 0;
            while (y>0){
                t = x;
                x = y;
                y = t%y;
            }
            System.out.println(x);
    }
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int ans = 0;
        gcd(a,b);
    }
}