import java.util.Scanner;

public class Main{

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

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

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		int temp = 0;
		if(x == y) System.out.println(x);
		else if(x >= y) {
			while(x % y > 0) {
				temp = x % y;
				x = y;
				y = temp;
			}
			System.out.println(temp);
		}
		else {
			while(y % x > 0) {
				temp = y % x;
				y = x;
				x = temp;
			}
			System.out.println(temp);
		}
	}
} Main
import java.util.Scanner;

public class Main{

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

