import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int x = num.nextInt();
        int y = num.nextInt();
        int result = 0;

        if(x < y) {
            int t = x;
            x = y;
            y = t;
        }

        while(true) {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        }
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int x = num.nextInt();
        int y = num.nextInt();
        int result = 0;

        if(x < y) {
            int t = x;
            x = y;
            y = t;
        }

        while(true) {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        }
        
    }
} Main public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int x = num.nextInt();
        int y = num.nextInt();
        int result = 0;

        if(x < y) {
            int t = x;
            x = y;
            y = t;
        }

        while(true) {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        }
        
    } main {
        Scanner num = new Scanner(System.in);
        int x = num.nextInt();
        int y = num.nextInt();
        int result = 0;

        if(x < y) {
            int t = x;
            x = y;
            y = t;
        }

        while(true) {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        }
        
    } Scanner num = new Scanner(System.in); num new Scanner(System.in) int x = num.nextInt(); x num.nextInt() num.nextInt num int y = num.nextInt(); y num.nextInt() num.nextInt num int result = 0; result 0 if(x < y) {
            int t = x;
            x = y;
            y = t;
        } x < y x y {
            int t = x;
            x = y;
            y = t;
        } int t = x; t x x = y x y y = t y t while(true) {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        } true {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        } int z = x % y; z x % y x y x = y x y y = z y z if(y == 0) {
                System.out.println(x);
                break;
            } y == 0 y 0 {
                System.out.println(x);
                break;
            } System.out.println(x) System.out.println System.out System System.out x break; String[] args args public class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int x = num.nextInt();
        int y = num.nextInt();
        int result = 0;

        if(x < y) {
            int t = x;
            x = y;
            y = t;
        }

        while(true) {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        }
        
    }
} public class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int x = num.nextInt();
        int y = num.nextInt();
        int result = 0;

        if(x < y) {
            int t = x;
            x = y;
            y = t;
        }

        while(true) {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        }
        
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int x = num.nextInt();
        int y = num.nextInt();
        int result = 0;

        if(x < y) {
            int t = x;
            x = y;
            y = t;
        }

        while(true) {
            int z = x % y;
            x = y;
            y = z;
            if(y == 0) {
                System.out.println(x);
                break;
            }
        }
        
    }
}
