import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(GCV(a, b));
    }

    public static int GCV(int a, int b) {
        if (b == 0) {
            return a;
        }
        return GCV(b, a%b);
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(GCV(a, b));
    }

    public static int GCV(int a, int b) {
        if (b == 0) {
            return a;
        }
        return GCV(b, a%b);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(GCV(a, b));
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(GCV(a, b));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc if(a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        } a < b a b {
            int tmp = a;
            a = b;
            b = tmp;
        } int tmp = a; tmp a a = b a b b = tmp b tmp System.out.println(GCV(a, b)) System.out.println System.out System System.out GCV(a, b) GCV a b String[] args args public static int GCV(int a, int b) {
        if (b == 0) {
            return a;
        }
        return GCV(b, a%b);
    } GCV {
        if (b == 0) {
            return a;
        }
        return GCV(b, a%b);
    } if (b == 0) {
            return a;
        } b == 0 b 0 {
            return a;
        } return a; a return GCV(b, a%b); GCV(b, a%b) GCV b a%b a b int a a int b b public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(GCV(a, b));
    }

    public static int GCV(int a, int b) {
        if (b == 0) {
            return a;
        }
        return GCV(b, a%b);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(GCV(a, b));
    }

    public static int GCV(int a, int b) {
        if (b == 0) {
            return a;
        }
        return GCV(b, a%b);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(GCV(a, b));
    }

    public static int GCV(int a, int b) {
        if (b == 0) {
            return a;
        }
        return GCV(b, a%b);
    }
}

