import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int[] ary = getAry(breader);
		int a = ary[0];
		int b = ary[1];
		int c = 1;
		while( true ) {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		}
		System.out.println(b);
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static void putAry(int[] ary) {
		for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int[] ary = getAry(breader);
		int a = ary[0];
		int b = ary[1];
		int c = 1;
		while( true ) {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		}
		System.out.println(b);
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static void putAry(int[] ary) {
		for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}

} Main public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int[] ary = getAry(breader);
		int a = ary[0];
		int b = ary[1];
		int c = 1;
		while( true ) {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		}
		System.out.println(b);
	} main {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int[] ary = getAry(breader);
		int a = ary[0];
		int b = ary[1];
		int c = 1;
		while( true ) {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		}
		System.out.println(b);
	} BufferedReader breader = getReader(); breader getReader() getReader int[] ary = getAry(breader); ary getAry(breader) getAry breader int a = ary[0]; a ary[0] ary 0 int b = ary[1]; b ary[1] ary 1 int c = 1; c 1 while( true ) {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		} true {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		} c = a%b c a%b a b if ( c == 0) break; c == 0 c 0 break; a = b a b b = c b c System.out.println(b) System.out.println System.out System System.out b String[] args args public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	} getReader {
		return( new BufferedReader(new InputStreamReader(System.in)));
	} return( new BufferedReader(new InputStreamReader(System.in))); ( new BufferedReader(new InputStreamReader(System.in))) public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	} getInt {
		String line = br.readLine();
		return Integer.valueOf(line);
	} String line = br.readLine(); line br.readLine() br.readLine br return Integer.valueOf(line); Integer.valueOf(line) Integer.valueOf Integer line BufferedReader br br public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	} getAry {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	} String line = br.readLine(); line br.readLine() br.readLine br String[] nstr = line.split(" "); nstr line.split(" ") line.split line " " int[] n = new int[nstr.length]; n new int[nstr.length] nstr.length nstr nstr.length for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		} int i=0 ; int i=0 ; i 0 i < nstr.length i nstr.length nstr nstr.length i++ i++ i {
			n[i] = Integer.valueOf(nstr[i]);
		} {
			n[i] = Integer.valueOf(nstr[i]);
		} n[i] = Integer.valueOf(nstr[i]) n[i] n i Integer.valueOf(nstr[i]) Integer.valueOf Integer nstr[i] nstr i return n; n BufferedReader br br public static void putAry(int[] ary) {
		for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	} putAry {
		for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	} for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		} int i = 0; int i = 0; i 0 i < ary.length i ary.length ary ary.length i++ i++ i {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		} {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		} System.out.print(ary[i]) System.out.print System.out System System.out ary[i] ary i if ( i < ary.length-1) {
				System.out.print(" ");
			} i < ary.length-1 i ary.length-1 ary.length ary ary.length 1 {
				System.out.print(" ");
			} System.out.print(" ") System.out.print System.out System System.out " " System.out.println("") System.out.println System.out System System.out "" int[] ary ary public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int[] ary = getAry(breader);
		int a = ary[0];
		int b = ary[1];
		int c = 1;
		while( true ) {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		}
		System.out.println(b);
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static void putAry(int[] ary) {
		for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}

} public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int[] ary = getAry(breader);
		int a = ary[0];
		int b = ary[1];
		int c = 1;
		while( true ) {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		}
		System.out.println(b);
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static void putAry(int[] ary) {
		for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int[] ary = getAry(breader);
		int a = ary[0];
		int b = ary[1];
		int c = 1;
		while( true ) {
			c = a%b;
			if ( c == 0) break;
			a = b;
			b = c;
		}
		System.out.println(b);
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static void putAry(int[] ary) {
		for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}

}