import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        
        if (y > x) {
        	int tmp = x;
        	x = y;
        	y = tmp;
        }
        
        while (x >= y) {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        }
        
        System.out.println(y);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        
        if (y > x) {
        	int tmp = x;
        	x = y;
        	y = tmp;
        }
        
        while (x >= y) {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        }
        
        System.out.println(y);
	}

} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        
        if (y > x) {
        	int tmp = x;
        	x = y;
        	y = tmp;
        }
        
        while (x >= y) {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        }
        
        System.out.println(y);
	} main {
		Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        
        if (y > x) {
        	int tmp = x;
        	x = y;
        	y = tmp;
        }
        
        while (x >= y) {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        }
        
        System.out.println(y);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int x = in.nextInt(); x in.nextInt() in.nextInt in int y = in.nextInt(); y in.nextInt() in.nextInt in 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 while (x >= y) {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        } x >= y x y {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        } if (x % y == 0) {
        		break;
        	} x % y == 0 x % y x y 0 {
        		break;
        	} break; int temp = y; temp y y = x % temp y x % temp x temp x = temp x temp System.out.println(y) System.out.println System.out System System.out y String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        
        if (y > x) {
        	int tmp = x;
        	x = y;
        	y = tmp;
        }
        
        while (x >= y) {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        }
        
        System.out.println(y);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        
        if (y > x) {
        	int tmp = x;
        	x = y;
        	y = tmp;
        }
        
        while (x >= y) {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        }
        
        System.out.println(y);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        
        if (y > x) {
        	int tmp = x;
        	x = y;
        	y = tmp;
        }
        
        while (x >= y) {
        	if (x % y == 0) {
        		break;
        	}
        	int temp = y;
        	y = x % temp;
        	x = temp;
        }
        
        System.out.println(y);
	}

}
