import java.util.Scanner;

public class Main {
	void run() {
		// 入力
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int mod;
		do {
			mod = a%b;
			a = b;
			b = mod;
		} while(mod != 0);
		// 出力
		System.out.println(a);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		// 入力
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int mod;
		do {
			mod = a%b;
			a = b;
			b = mod;
		} while(mod != 0);
		// 出力
		System.out.println(a);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		// 入力
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int mod;
		do {
			mod = a%b;
			a = b;
			b = mod;
		} while(mod != 0);
		// 出力
		System.out.println(a);
	} run {
		// 入力
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int mod;
		do {
			mod = a%b;
			a = b;
			b = mod;
		} while(mod != 0);
		// 出力
		System.out.println(a);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int mod; mod do {
			mod = a%b;
			a = b;
			b = mod;
		} while(mod != 0); mod != 0 mod 0 {
			mod = a%b;
			a = b;
			b = mod;
		} mod = a%b mod a%b a b a = b a b b = mod b mod System.out.println(a) System.out.println System.out System System.out a public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		// 入力
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int mod;
		do {
			mod = a%b;
			a = b;
			b = mod;
		} while(mod != 0);
		// 出力
		System.out.println(a);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		// 入力
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int mod;
		do {
			mod = a%b;
			a = b;
			b = mod;
		} while(mod != 0);
		// 出力
		System.out.println(a);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run() {
		// 入力
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int mod;
		do {
			mod = a%b;
			a = b;
			b = mod;
		} while(mod != 0);
		// 出力
		System.out.println(a);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}
