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

public class Main{

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int a = Integer.parseInt(t[0]);
        int b = Integer.parseInt(t[1]);
        System.out.println(gcd(a, b));
    }

    public static int  gcd(int x, int y){
        int r;
        if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main{

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int a = Integer.parseInt(t[0]);
        int b = Integer.parseInt(t[1]);
        System.out.println(gcd(a, b));
    }

    public static int  gcd(int x, int y){
        int r;
        if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }

} Main public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int a = Integer.parseInt(t[0]);
        int b = Integer.parseInt(t[1]);
        System.out.println(gcd(a, b));
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int a = Integer.parseInt(t[0]);
        int b = Integer.parseInt(t[1]);
        System.out.println(gcd(a, b));
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] t = br.readLine().split(" "); t br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int a = Integer.parseInt(t[0]); a Integer.parseInt(t[0]) Integer.parseInt Integer t[0] t 0 int b = Integer.parseInt(t[1]); b Integer.parseInt(t[1]) Integer.parseInt Integer t[1] t 1 System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b String[] args args public static int  gcd(int x, int y){
        int r;
        if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    } gcd {
        int r;
        if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    } int r; r if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        } x < y x y {
            int temp;
            temp = x;
            x = y;
            y = temp;
        } int temp; temp temp = x temp x x = y x y y = temp y temp while(y > 0){
            r = x % y;
            x = y;
            y = r;
        } y > 0 y 0 {
            r = x % y;
            x = y;
            y = r;
        } r = x % y r x % y x y x = y x y y = r y r return x; x int x x int y y public class Main{

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int a = Integer.parseInt(t[0]);
        int b = Integer.parseInt(t[1]);
        System.out.println(gcd(a, b));
    }

    public static int  gcd(int x, int y){
        int r;
        if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }

} public class Main{

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int a = Integer.parseInt(t[0]);
        int b = Integer.parseInt(t[1]);
        System.out.println(gcd(a, b));
    }

    public static int  gcd(int x, int y){
        int r;
        if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }

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

public class Main{

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int a = Integer.parseInt(t[0]);
        int b = Integer.parseInt(t[1]);
        System.out.println(gcd(a, b));
    }

    public static int  gcd(int x, int y){
        int r;
        if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }

}