import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

/*Question
/??????????????¶??° x, y ?????\?????¨???????????????????????§??¬?´???°????±???????????????°????????????????????????????????????
/???????????´??° x ??¨ y ???????????????x ?? d ??¨ y ?? d ??????????????¨?????? 0 ??¨?????? d ??????????????§???????????????x ??¨ y ????????§??¬?´???°???Greatest Common Divisor?????¨?¨?????????????
/????????°???35 ??¨14 ????????§??¬?´???° gcd (35, 14) ??? 7 ??¨???????????????????????????35 ????´???°{1, 5, 7, 35}???14 ????´???° {1, 2, 7, 14} ?????¬?´???° {1, 7} ????????§?????¨??????????????? 
*/

/*Input
/x ??¨ y ?????????????????????????????§?????????????????????????????? 
*/

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		String[] st = sc.readLine().split(" ");
		int x = Integer.parseInt(st[0]);
		int y = Integer.parseInt(st[1]);
		GCD(Math.max(x,y),Math.min(x,y));
	}

	/*GCD????????????
	/?????°??????????????§??¬?´???°?????¢???????????????
	/x % y???o??§?????????????????????
	/?????????x % y????¨??????????????????\??????y % t?????°?????????
	*/

	public static void GCD(int x,int y) {
		//????????????x % y???????´???????????????????
		int t;
		while ((t = x % y) != 0) {
			x = y;
			y = t;
		}
		System.out.println(y);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.lang.Math; Math java.lang public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		String[] st = sc.readLine().split(" ");
		int x = Integer.parseInt(st[0]);
		int y = Integer.parseInt(st[1]);
		GCD(Math.max(x,y),Math.min(x,y));
	}

	/*GCD????????????
	/?????°??????????????§??¬?´???°?????¢???????????????
	/x % y???o??§?????????????????????
	/?????????x % y????¨??????????????????\??????y % t?????°?????????
	*/

	public static void GCD(int x,int y) {
		//????????????x % y???????´???????????????????
		int t;
		while ((t = x % y) != 0) {
			x = y;
			y = t;
		}
		System.out.println(y);
	}
} Main public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		String[] st = sc.readLine().split(" ");
		int x = Integer.parseInt(st[0]);
		int y = Integer.parseInt(st[1]);
		GCD(Math.max(x,y),Math.min(x,y));
	} main {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		String[] st = sc.readLine().split(" ");
		int x = Integer.parseInt(st[0]);
		int y = Integer.parseInt(st[1]);
		GCD(Math.max(x,y),Math.min(x,y));
	} BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); sc new BufferedReader(new InputStreamReader(System.in)) String[] st = sc.readLine().split(" "); st sc.readLine().split(" ") sc.readLine().split sc.readLine() sc.readLine sc " " int x = Integer.parseInt(st[0]); x Integer.parseInt(st[0]) Integer.parseInt Integer st[0] st 0 int y = Integer.parseInt(st[1]); y Integer.parseInt(st[1]) Integer.parseInt Integer st[1] st 1 GCD(Math.max(x,y),Math.min(x,y)) GCD Math.max(x,y) Math.max Math x y Math.min(x,y) Math.min Math x y String[] args args public static void GCD(int x,int y) {
		//????????????x % y???????´???????????????????
		int t;
		while ((t = x % y) != 0) {
			x = y;
			y = t;
		}
		System.out.println(y);
	} GCD {
		//????????????x % y???????´???????????????????
		int t;
		while ((t = x % y) != 0) {
			x = y;
			y = t;
		}
		System.out.println(y);
	} int t; t while ((t = x % y) != 0) {
			x = y;
			y = t;
		} (t = x % y) != 0 (t = x % y) t x % y x y 0 {
			x = y;
			y = t;
		} x = y x y y = t y t System.out.println(y) System.out.println System.out System System.out y int x x int y y public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		String[] st = sc.readLine().split(" ");
		int x = Integer.parseInt(st[0]);
		int y = Integer.parseInt(st[1]);
		GCD(Math.max(x,y),Math.min(x,y));
	}

	/*GCD????????????
	/?????°??????????????§??¬?´???°?????¢???????????????
	/x % y???o??§?????????????????????
	/?????????x % y????¨??????????????????\??????y % t?????°?????????
	*/

	public static void GCD(int x,int y) {
		//????????????x % y???????´???????????????????
		int t;
		while ((t = x % y) != 0) {
			x = y;
			y = t;
		}
		System.out.println(y);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		String[] st = sc.readLine().split(" ");
		int x = Integer.parseInt(st[0]);
		int y = Integer.parseInt(st[1]);
		GCD(Math.max(x,y),Math.min(x,y));
	}

	/*GCD????????????
	/?????°??????????????§??¬?´???°?????¢???????????????
	/x % y???o??§?????????????????????
	/?????????x % y????¨??????????????????\??????y % t?????°?????????
	*/

	public static void GCD(int x,int y) {
		//????????????x % y???????´???????????????????
		int t;
		while ((t = x % y) != 0) {
			x = y;
			y = t;
		}
		System.out.println(y);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

/*Question
/??????????????¶??° x, y ?????\?????¨???????????????????????§??¬?´???°????±???????????????°????????????????????????????????????
/???????????´??° x ??¨ y ???????????????x ?? d ??¨ y ?? d ??????????????¨?????? 0 ??¨?????? d ??????????????§???????????????x ??¨ y ????????§??¬?´???°???Greatest Common Divisor?????¨?¨?????????????
/????????°???35 ??¨14 ????????§??¬?´???° gcd (35, 14) ??? 7 ??¨???????????????????????????35 ????´???°{1, 5, 7, 35}???14 ????´???° {1, 2, 7, 14} ?????¬?´???° {1, 7} ????????§?????¨??????????????? 
*/

/*Input
/x ??¨ y ?????????????????????????????§?????????????????????????????? 
*/

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		String[] st = sc.readLine().split(" ");
		int x = Integer.parseInt(st[0]);
		int y = Integer.parseInt(st[1]);
		GCD(Math.max(x,y),Math.min(x,y));
	}

	/*GCD????????????
	/?????°??????????????§??¬?´???°?????¢???????????????
	/x % y???o??§?????????????????????
	/?????????x % y????¨??????????????????\??????y % t?????°?????????
	*/

	public static void GCD(int x,int y) {
		//????????????x % y???????´???????????????????
		int t;
		while ((t = x % y) != 0) {
			x = y;
			y = t;
		}
		System.out.println(y);
	}
}