import java.util.*;


public class Main{

	public static void main(String args[]){

		Scanner s = new Scanner(System.in);
		int num1 = s.nextInt();
		int num2 = s.nextInt();
		int surplus = 0;
		int i = 0;


		while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		}
	}
} import java.util.*; util.* java public class Main{

	public static void main(String args[]){

		Scanner s = new Scanner(System.in);
		int num1 = s.nextInt();
		int num2 = s.nextInt();
		int surplus = 0;
		int i = 0;


		while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		}
	}
} Main public static void main(String args[]){

		Scanner s = new Scanner(System.in);
		int num1 = s.nextInt();
		int num2 = s.nextInt();
		int surplus = 0;
		int i = 0;


		while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		}
	} main {

		Scanner s = new Scanner(System.in);
		int num1 = s.nextInt();
		int num2 = s.nextInt();
		int surplus = 0;
		int i = 0;


		while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		}
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int num1 = s.nextInt(); num1 s.nextInt() s.nextInt s int num2 = s.nextInt(); num2 s.nextInt() s.nextInt s int surplus = 0; surplus 0 int i = 0; i 0 while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		} i < 100000000 i 100000000 {
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		} if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			} num1>=num2 num1 num2 {
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			} surplus = num1%num2 surplus num1%num2 num1 num2 num1 = num2 num1 num2 num2 = surplus num2 surplus if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				} surplus == 0 surplus 0 {
					System.out.println(num1);
					break;
				} System.out.println(num1) System.out.println System.out System System.out num1 break; {
					i++;
				} i++ i if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			} num2>=num1 num2 num1 {
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			} surplus = num2%num1 surplus num2%num1 num2 num1 num1 = num2 num1 num2 num2 = surplus num2 surplus if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				} surplus == 0 surplus 0 {
					System.out.println(num2);
					break;
				} System.out.println(num2) System.out.println System.out System System.out num2 break; {
					i++;
				} i++ i String args[] args public class Main{

	public static void main(String args[]){

		Scanner s = new Scanner(System.in);
		int num1 = s.nextInt();
		int num2 = s.nextInt();
		int surplus = 0;
		int i = 0;


		while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		}
	}
} public class Main{

	public static void main(String args[]){

		Scanner s = new Scanner(System.in);
		int num1 = s.nextInt();
		int num2 = s.nextInt();
		int surplus = 0;
		int i = 0;


		while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		}
	}
} Main
import java.util.*;


public class Main{

	public static void main(String args[]){

		Scanner s = new Scanner(System.in);
		int num1 = s.nextInt();
		int num2 = s.nextInt();
		int surplus = 0;
		int i = 0;


		while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		}
	}
}
