import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int b  = number.nextInt();
		int c;

		if(a < b) {
			c = a;
			a = b;
			b = c;
		}
		do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0);
		System.out.println(b);
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int b  = number.nextInt();
		int c;

		if(a < b) {
			c = a;
			a = b;
			b = c;
		}
		do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0);
		System.out.println(b);
	}
} Main public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int b  = number.nextInt();
		int c;

		if(a < b) {
			c = a;
			a = b;
			b = c;
		}
		do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0);
		System.out.println(b);
	} main {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int b  = number.nextInt();
		int c;

		if(a < b) {
			c = a;
			a = b;
			b = c;
		}
		do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0);
		System.out.println(b);
	} Scanner number = new Scanner(System.in); number new Scanner(System.in) int a  = number.nextInt(); a number.nextInt() number.nextInt number int b  = number.nextInt(); b number.nextInt() number.nextInt number int c; c if(a < b) {
			c = a;
			a = b;
			b = c;
		} a < b a b {
			c = a;
			a = b;
			b = c;
		} c = a c a a = b a b b = c b c do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0); a % b != 0 a % b a b 0 {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		} c = b c b b = a % b b a % b a b a = c a c if(b == 0) {
				b = a;
				break;
			} b == 0 b 0 {
				b = a;
				break;
			} b = a b a break; System.out.println(b) System.out.println System.out System System.out b String[] args args public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int b  = number.nextInt();
		int c;

		if(a < b) {
			c = a;
			a = b;
			b = c;
		}
		do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0);
		System.out.println(b);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int b  = number.nextInt();
		int c;

		if(a < b) {
			c = a;
			a = b;
			b = c;
		}
		do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0);
		System.out.println(b);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int b  = number.nextInt();
		int c;

		if(a < b) {
			c = a;
			a = b;
			b = c;
		}
		do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0);
		System.out.println(b);
	}
}

