import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		
		int ans = gcd(x,y);
		System.out.println(ans);
	}
	public static int gcd(int x, int y) {
		if(x == 0) return y;
		if(x == y) return x;
		return gcd(y%x,x);
	}
} import java.io.*; io.* java import java.util.ArrayDeque; ArrayDeque java.util import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		
		int ans = gcd(x,y);
		System.out.println(ans);
	}
	public static int gcd(int x, int y) {
		if(x == 0) return y;
		if(x == y) return x;
		return gcd(y%x,x);
	}
} Main static String a; a public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		
		int ans = gcd(x,y);
		System.out.println(ans);
	} main {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		
		int ans = gcd(x,y);
		System.out.println(ans);
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int x = stdIn.nextInt(); x stdIn.nextInt() stdIn.nextInt stdIn int y = stdIn.nextInt(); y stdIn.nextInt() stdIn.nextInt stdIn if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		} x < y x y {
			int tmp = x;
			x = y;
			y = tmp;
		} int tmp = x; tmp x x = y x y y = tmp y tmp int ans = gcd(x,y); ans gcd(x,y) gcd x y System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static int gcd(int x, int y) {
		if(x == 0) return y;
		if(x == y) return x;
		return gcd(y%x,x);
	} gcd {
		if(x == 0) return y;
		if(x == y) return x;
		return gcd(y%x,x);
	} if(x == 0) return y; x == 0 x 0 return y; y if(x == y) return x; x == y x y return x; x return gcd(y%x,x); gcd(y%x,x) gcd y%x y x x int x x int y y public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		
		int ans = gcd(x,y);
		System.out.println(ans);
	}
	public static int gcd(int x, int y) {
		if(x == 0) return y;
		if(x == y) return x;
		return gcd(y%x,x);
	}
} public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		
		int ans = gcd(x,y);
		System.out.println(ans);
	}
	public static int gcd(int x, int y) {
		if(x == 0) return y;
		if(x == y) return x;
		return gcd(y%x,x);
	}
} Main
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		
		int ans = gcd(x,y);
		System.out.println(ans);
	}
	public static int gcd(int x, int y) {
		if(x == 0) return y;
		if(x == y) return x;
		return gcd(y%x,x);
	}
}