import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a == b) {
            System.out.println(a);
            return;
        }
        if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        System.out.println(gcd(a, b));
    }
    
    private int gcd(int x, int y) {
        if (y == 0) return x;
        if (y <= 1 || x <= y) return 1;
        return gcd(y, x%y);
    }
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
} import java.util.*; util.* java public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a == b) {
            System.out.println(a);
            return;
        }
        if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        System.out.println(gcd(a, b));
    }
    
    private int gcd(int x, int y) {
        if (y == 0) return x;
        if (y <= 1 || x <= y) return 1;
        return gcd(y, x%y);
    }
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
} Main public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    } main {
        Main main = new Main();
        main.solv();
    } Main main = new Main(); main new Main() main.solv() main.solv main String[] args args private void solv() {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a == b) {
            System.out.println(a);
            return;
        }
        if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        System.out.println(gcd(a, b));
    } solv {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a == b) {
            System.out.println(a);
            return;
        }
        if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        System.out.println(gcd(a, b));
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int a = input.nextInt(); a input.nextInt() input.nextInt input int b = input.nextInt(); b input.nextInt() input.nextInt input if (a == b) {
            System.out.println(a);
            return;
        } a == b a b {
            System.out.println(a);
            return;
        } System.out.println(a) System.out.println System.out System System.out a return; if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        } a < b a b {
            int temp = a;
            a = b;
            b = temp;
        } int temp = a; temp a a = b a b b = temp b temp System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b private int gcd(int x, int y) {
        if (y == 0) return x;
        if (y <= 1 || x <= y) return 1;
        return gcd(y, x%y);
    } gcd {
        if (y == 0) return x;
        if (y <= 1 || x <= y) return 1;
        return gcd(y, x%y);
    } if (y == 0) return x; y == 0 y 0 return x; x if (y <= 1 || x <= y) return 1; y <= 1 || x <= y y <= 1 y 1 x <= y x y return 1; 1 return gcd(y, x%y); gcd(y, x%y) gcd y x%y x y int x x int y y private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    } print {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    } StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (int x : xs) sb.append(x).append(' '); int x xs sb.append(x).append(' '); sb.append(x).append(' ') sb.append(x).append sb.append(x) sb.append sb x ' ' System.out.println(sb.toString().trim()) System.out.println System.out System System.out sb.toString().trim() sb.toString().trim sb.toString() sb.toString sb int[] xs xs public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a == b) {
            System.out.println(a);
            return;
        }
        if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        System.out.println(gcd(a, b));
    }
    
    private int gcd(int x, int y) {
        if (y == 0) return x;
        if (y <= 1 || x <= y) return 1;
        return gcd(y, x%y);
    }
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
} public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a == b) {
            System.out.println(a);
            return;
        }
        if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        System.out.println(gcd(a, b));
    }
    
    private int gcd(int x, int y) {
        if (y == 0) return x;
        if (y <= 1 || x <= y) return 1;
        return gcd(y, x%y);
    }
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
} Main
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a == b) {
            System.out.println(a);
            return;
        }
        if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        System.out.println(gcd(a, b));
    }
    
    private int gcd(int x, int y) {
        if (y == 0) return x;
        if (y <= 1 || x <= y) return 1;
        return gcd(y, x%y);
    }
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
}