import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int int1 = input.nextInt();
		int int2 = input.nextInt();
		int gcd = 1;
		
		if(int2 > int1) {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		}
		while(int1 >= int2) {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		}
		System.out.println(gcd);
	}
} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int int1 = input.nextInt();
		int int2 = input.nextInt();
		int gcd = 1;
		
		if(int2 > int1) {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		}
		while(int1 >= int2) {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		}
		System.out.println(gcd);
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int int1 = input.nextInt();
		int int2 = input.nextInt();
		int gcd = 1;
		
		if(int2 > int1) {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		}
		while(int1 >= int2) {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		}
		System.out.println(gcd);
	} main {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int int1 = input.nextInt();
		int int2 = input.nextInt();
		int gcd = 1;
		
		if(int2 > int1) {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		}
		while(int1 >= int2) {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		}
		System.out.println(gcd);
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) int int1 = input.nextInt(); int1 input.nextInt() input.nextInt input int int2 = input.nextInt(); int2 input.nextInt() input.nextInt input int gcd = 1; gcd 1 if(int2 > int1) {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		} int2 > int1 int2 int1 {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		} int temp = int1; temp int1 int1 = int2 int1 int2 int2 = temp int2 temp while(int1 >= int2) {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		} int1 >= int2 int1 int2 {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		} int temp = int2; temp int2 int2 = int1 % int2 int2 int1 % int2 int1 int2 if(int2 == 0) {
				gcd = temp;
				break;
			} int2 == 0 int2 0 {
				gcd = temp;
				break;
			} gcd = temp gcd temp break; int1 = temp int1 temp System.out.println(gcd) System.out.println System.out System System.out gcd String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int int1 = input.nextInt();
		int int2 = input.nextInt();
		int gcd = 1;
		
		if(int2 > int1) {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		}
		while(int1 >= int2) {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		}
		System.out.println(gcd);
	}
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int int1 = input.nextInt();
		int int2 = input.nextInt();
		int gcd = 1;
		
		if(int2 > int1) {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		}
		while(int1 >= int2) {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		}
		System.out.println(gcd);
	}
} Main
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int int1 = input.nextInt();
		int int2 = input.nextInt();
		int gcd = 1;
		
		if(int2 > int1) {
			int temp = int1;
			int1 = int2;
			int2 = temp;
		}
		while(int1 >= int2) {
			int temp = int2;
			int2 = int1 % int2;
			if(int2 == 0) {
				gcd = temp;
				break;
			}
			int1 = temp;
		}
		System.out.println(gcd);
	}
}
