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

public class Main{

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[] numArray = parseInt(getSplitLine(line));

        int x;
        int y;
        if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        }

//計算
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }

        System.out.println(y);
    }

    private static String[] getSplitLine(String line) {
        return line.split("\\s");
    }

    private static int[] parseInt(String[] line) {
        int[] numArray = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        }
        return numArray;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[] numArray = parseInt(getSplitLine(line));

        int x;
        int y;
        if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        }

//計算
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }

        System.out.println(y);
    }

    private static String[] getSplitLine(String line) {
        return line.split("\\s");
    }

    private static int[] parseInt(String[] line) {
        int[] numArray = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        }
        return numArray;
    }
} Main public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[] numArray = parseInt(getSplitLine(line));

        int x;
        int y;
        if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        }

//計算
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }

        System.out.println(y);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[] numArray = parseInt(getSplitLine(line));

        int x;
        int y;
        if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        }

//計算
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }

        System.out.println(y);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = br.readLine(); line br.readLine() br.readLine br int[] numArray = parseInt(getSplitLine(line)); numArray parseInt(getSplitLine(line)) parseInt getSplitLine(line) getSplitLine line int x; x int y; y if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        } numArray[0] > numArray[1] numArray[0] numArray 0 numArray[1] numArray 1 {
            x = numArray[0];
            y = numArray[1];
        } x = numArray[0] x numArray[0] numArray 0 y = numArray[1] y numArray[1] numArray 1 {
            x = numArray[1];
            y = numArray[0];
        } x = numArray[1] x numArray[1] numArray 1 y = numArray[0] y numArray[0] numArray 0 int tmp; tmp while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        } (tmp = x % y) != 0 (tmp = x % y) tmp x % y x y 0 {
            x = y;
            y = tmp;
        } x = y x y y = tmp y tmp System.out.println(y) System.out.println System.out System System.out y String args[] args private static String[] getSplitLine(String line) {
        return line.split("\\s");
    } getSplitLine {
        return line.split("\\s");
    } return line.split("\\s"); line.split("\\s") line.split line "\\s" String line line private static int[] parseInt(String[] line) {
        int[] numArray = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        }
        return numArray;
    } parseInt {
        int[] numArray = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        }
        return numArray;
    } int[] numArray = new int[line.length]; numArray new int[line.length] line.length line line.length for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        } int i = 0; int i = 0; i 0 i < line.length i line.length line line.length i++ i++ i {
            numArray[i] = Integer.parseInt(line[i]);
        } {
            numArray[i] = Integer.parseInt(line[i]);
        } numArray[i] = Integer.parseInt(line[i]) numArray[i] numArray i Integer.parseInt(line[i]) Integer.parseInt Integer line[i] line i return numArray; numArray String[] line line public class Main{

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[] numArray = parseInt(getSplitLine(line));

        int x;
        int y;
        if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        }

//計算
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }

        System.out.println(y);
    }

    private static String[] getSplitLine(String line) {
        return line.split("\\s");
    }

    private static int[] parseInt(String[] line) {
        int[] numArray = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        }
        return numArray;
    }
} public class Main{

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[] numArray = parseInt(getSplitLine(line));

        int x;
        int y;
        if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        }

//計算
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }

        System.out.println(y);
    }

    private static String[] getSplitLine(String line) {
        return line.split("\\s");
    }

    private static int[] parseInt(String[] line) {
        int[] numArray = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        }
        return numArray;
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[] numArray = parseInt(getSplitLine(line));

        int x;
        int y;
        if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        }

//計算
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }

        System.out.println(y);
    }

    private static String[] getSplitLine(String line) {
        return line.split("\\s");
    }

    private static int[] parseInt(String[] line) {
        int[] numArray = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        }
        return numArray;
    }
}
