import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Greatest Common Divisor
 * 
 *
 */
public class Main {
    
    public static void main(String[] args) {
        // input data
        List<String> input = inputLines();
        
        // get input
        int x = Integer.valueOf(input.get(0).split(" ")[0]);
        int y = Integer.valueOf(input.get(0).split(" ")[1]);
        if (y > x) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        int gcd = 0;

        // main logic
        
        gcd = gcd(x,y);

        output(gcd);
    }

    private static int gcd(int n,int m) {
        if (m == 0) {
            return n;
        }
        return gcd(m, n % m);
    }

    private static List<String> mocups() {
        List<String> input = Arrays.asList(
                "6 15"
                );
        return input;
    }

    /** output data */
    private static void output(Object o) {
        System.out.println(o);
    }
    private static void output(String[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(int[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(Object[] o) {
        System.out.println(Arrays.toString(o));
    }

    /** input data */
    private static List<String> inputLines() {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    }

} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main(String[] args) {
        // input data
        List<String> input = inputLines();
        
        // get input
        int x = Integer.valueOf(input.get(0).split(" ")[0]);
        int y = Integer.valueOf(input.get(0).split(" ")[1]);
        if (y > x) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        int gcd = 0;

        // main logic
        
        gcd = gcd(x,y);

        output(gcd);
    }

    private static int gcd(int n,int m) {
        if (m == 0) {
            return n;
        }
        return gcd(m, n % m);
    }

    private static List<String> mocups() {
        List<String> input = Arrays.asList(
                "6 15"
                );
        return input;
    }

    /** output data */
    private static void output(Object o) {
        System.out.println(o);
    }
    private static void output(String[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(int[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(Object[] o) {
        System.out.println(Arrays.toString(o));
    }

    /** input data */
    private static List<String> inputLines() {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    }

} Main public static void main(String[] args) {
        // input data
        List<String> input = inputLines();
        
        // get input
        int x = Integer.valueOf(input.get(0).split(" ")[0]);
        int y = Integer.valueOf(input.get(0).split(" ")[1]);
        if (y > x) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        int gcd = 0;

        // main logic
        
        gcd = gcd(x,y);

        output(gcd);
    } main {
        // input data
        List<String> input = inputLines();
        
        // get input
        int x = Integer.valueOf(input.get(0).split(" ")[0]);
        int y = Integer.valueOf(input.get(0).split(" ")[1]);
        if (y > x) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        int gcd = 0;

        // main logic
        
        gcd = gcd(x,y);

        output(gcd);
    } List<String> input = inputLines(); input inputLines() inputLines int x = Integer.valueOf(input.get(0).split(" ")[0]); x Integer.valueOf(input.get(0).split(" ")[0]) Integer.valueOf Integer input.get(0).split(" ")[0] input.get(0).split(" ") input.get(0).split input.get(0) input.get input 0 " " 0 int y = Integer.valueOf(input.get(0).split(" ")[1]); y Integer.valueOf(input.get(0).split(" ")[1]) Integer.valueOf Integer input.get(0).split(" ")[1] input.get(0).split(" ") input.get(0).split input.get(0) input.get input 0 " " 1 if (y > x) {
            int tmp = x;
            x = y;
            y = tmp;
        } y > x y x {
            int tmp = x;
            x = y;
            y = tmp;
        } int tmp = x; tmp x x = y x y y = tmp y tmp int gcd = 0; gcd 0 gcd = gcd(x,y) gcd gcd(x,y) gcd x y output(gcd) output gcd String[] args args private static int gcd(int n,int m) {
        if (m == 0) {
            return n;
        }
        return gcd(m, n % m);
    } gcd {
        if (m == 0) {
            return n;
        }
        return gcd(m, n % m);
    } if (m == 0) {
            return n;
        } m == 0 m 0 {
            return n;
        } return n; n return gcd(m, n % m); gcd(m, n % m) gcd m n % m n m int n n int m m private static List<String> mocups() {
        List<String> input = Arrays.asList(
                "6 15"
                );
        return input;
    } mocups {
        List<String> input = Arrays.asList(
                "6 15"
                );
        return input;
    } List<String> input = Arrays.asList(
                "6 15"
                ); input Arrays.asList(
                "6 15"
                ) Arrays.asList Arrays "6 15" return input; input /** output data */
    private static void output(Object o) {
        System.out.println(o);
    } output {
        System.out.println(o);
    } System.out.println(o) System.out.println System.out System System.out o Object o o private static void output(String[] o) {
        System.out.println(Arrays.toString(o));
    } output {
        System.out.println(Arrays.toString(o));
    } System.out.println(Arrays.toString(o)) System.out.println System.out System System.out Arrays.toString(o) Arrays.toString Arrays o String[] o o private static void output(int[] o) {
        System.out.println(Arrays.toString(o));
    } output {
        System.out.println(Arrays.toString(o));
    } System.out.println(Arrays.toString(o)) System.out.println System.out System System.out Arrays.toString(o) Arrays.toString Arrays o int[] o o private static void output(Object[] o) {
        System.out.println(Arrays.toString(o));
    } output {
        System.out.println(Arrays.toString(o));
    } System.out.println(Arrays.toString(o)) System.out.println System.out System System.out Arrays.toString(o) Arrays.toString Arrays o Object[] o o /** input data */
    private static List<String> inputLines() {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    } inputLines {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) List<String> input = new ArrayList<String>(); input new ArrayList<String>() while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        } in.hasNext() in.hasNext in {
            String buf = in.nextLine();
            input.add(buf);
        } String buf = in.nextLine(); buf in.nextLine() in.nextLine in input.add(buf) input.add input buf in.close() in.close in return input; input public class Main {
    
    public static void main(String[] args) {
        // input data
        List<String> input = inputLines();
        
        // get input
        int x = Integer.valueOf(input.get(0).split(" ")[0]);
        int y = Integer.valueOf(input.get(0).split(" ")[1]);
        if (y > x) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        int gcd = 0;

        // main logic
        
        gcd = gcd(x,y);

        output(gcd);
    }

    private static int gcd(int n,int m) {
        if (m == 0) {
            return n;
        }
        return gcd(m, n % m);
    }

    private static List<String> mocups() {
        List<String> input = Arrays.asList(
                "6 15"
                );
        return input;
    }

    /** output data */
    private static void output(Object o) {
        System.out.println(o);
    }
    private static void output(String[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(int[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(Object[] o) {
        System.out.println(Arrays.toString(o));
    }

    /** input data */
    private static List<String> inputLines() {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    }

} public class Main {
    
    public static void main(String[] args) {
        // input data
        List<String> input = inputLines();
        
        // get input
        int x = Integer.valueOf(input.get(0).split(" ")[0]);
        int y = Integer.valueOf(input.get(0).split(" ")[1]);
        if (y > x) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        int gcd = 0;

        // main logic
        
        gcd = gcd(x,y);

        output(gcd);
    }

    private static int gcd(int n,int m) {
        if (m == 0) {
            return n;
        }
        return gcd(m, n % m);
    }

    private static List<String> mocups() {
        List<String> input = Arrays.asList(
                "6 15"
                );
        return input;
    }

    /** output data */
    private static void output(Object o) {
        System.out.println(o);
    }
    private static void output(String[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(int[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(Object[] o) {
        System.out.println(Arrays.toString(o));
    }

    /** input data */
    private static List<String> inputLines() {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    }

} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Greatest Common Divisor
 * 
 *
 */
public class Main {
    
    public static void main(String[] args) {
        // input data
        List<String> input = inputLines();
        
        // get input
        int x = Integer.valueOf(input.get(0).split(" ")[0]);
        int y = Integer.valueOf(input.get(0).split(" ")[1]);
        if (y > x) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        int gcd = 0;

        // main logic
        
        gcd = gcd(x,y);

        output(gcd);
    }

    private static int gcd(int n,int m) {
        if (m == 0) {
            return n;
        }
        return gcd(m, n % m);
    }

    private static List<String> mocups() {
        List<String> input = Arrays.asList(
                "6 15"
                );
        return input;
    }

    /** output data */
    private static void output(Object o) {
        System.out.println(o);
    }
    private static void output(String[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(int[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(Object[] o) {
        System.out.println(Arrays.toString(o));
    }

    /** input data */
    private static List<String> inputLines() {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    }

}