import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		euclid(x,y);
	}
	public static void euclid(int x , int y)
	{
		int temp;
		if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		}
		if(x < y){
			temp = x;
			x = y;
			y = temp;
		}
		
		euclid(y,x % y);
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		euclid(x,y);
	}
	public static void euclid(int x , int y)
	{
		int temp;
		if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		}
		if(x < y){
			temp = x;
			x = y;
			y = temp;
		}
		
		euclid(y,x % y);
	}
} Main public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		euclid(x,y);
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		euclid(x,y);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc euclid(x,y) euclid x y String[] args args public static void euclid(int x , int y)
	{
		int temp;
		if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		}
		if(x < y){
			temp = x;
			x = y;
			y = temp;
		}
		
		euclid(y,x % y);
	} euclid {
		int temp;
		if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		}
		if(x < y){
			temp = x;
			x = y;
			y = temp;
		}
		
		euclid(y,x % y);
	} int temp; temp if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		} x == 0 || y == 0 x == 0 x 0 y == 0 y 0 {
			System.out.println((x+y));
			return ;
		} System.out.println((x+y)) System.out.println System.out System System.out (x+y) x y return ; if(x < y){
			temp = x;
			x = y;
			y = temp;
		} x < y x y {
			temp = x;
			x = y;
			y = temp;
		} temp = x temp x x = y x y y = temp y temp euclid(y,x % y) euclid y x % y x y int x x int y y public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		euclid(x,y);
	}
	public static void euclid(int x , int y)
	{
		int temp;
		if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		}
		if(x < y){
			temp = x;
			x = y;
			y = temp;
		}
		
		euclid(y,x % y);
	}
} public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		euclid(x,y);
	}
	public static void euclid(int x , int y)
	{
		int temp;
		if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		}
		if(x < y){
			temp = x;
			x = y;
			y = temp;
		}
		
		euclid(y,x % y);
	}
} Main
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		euclid(x,y);
	}
	public static void euclid(int x , int y)
	{
		int temp;
		if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		}
		if(x < y){
			temp = x;
			x = y;
			y = temp;
		}
		
		euclid(y,x % y);
	}
}