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);
	}
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz