import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		x= Integer.parseInt(strArr[0]);
		y = Integer.parseInt(strArr[1]);
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		x= Integer.parseInt(strArr[0]);
		y = Integer.parseInt(strArr[1]);
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

} Main public static int x; x public static int y; y public static int z; z public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		x= Integer.parseInt(strArr[0]);
		y = Integer.parseInt(strArr[1]);
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		x= Integer.parseInt(strArr[0]);
		y = Integer.parseInt(strArr[1]);
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] strArr = br.readLine().split(" "); strArr br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " x= Integer.parseInt(strArr[0]) x Integer.parseInt(strArr[0]) Integer.parseInt Integer strArr[0] strArr 0 y = Integer.parseInt(strArr[1]) y Integer.parseInt(strArr[1]) Integer.parseInt Integer strArr[1] strArr 1 if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		} x > y x y {
			solve(x,y);
		} solve(x,y) solve x y {
			solve(y,x);
		} solve(y,x) solve y x System.out.println(z) System.out.println System.out System System.out z String[] args args public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	} solve {
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	} z = big % small z big % small big small if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		} z == 0 z 0 {
			z = small;
		} z = small z small {
			solve(small,z);
		} solve(small,z) solve small z int big big int small small public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		x= Integer.parseInt(strArr[0]);
		y = Integer.parseInt(strArr[1]);
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

} public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		x= Integer.parseInt(strArr[0]);
		y = Integer.parseInt(strArr[1]);
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		x= Integer.parseInt(strArr[0]);
		y = Integer.parseInt(strArr[1]);
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

}