import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,gcd=2;
		a=scan.nextInt();
		b=scan.nextInt();
		if(a>=b){
			GCD(a,b);
		}
		else{
			GCD(b,a);
		}
	}
	public static void GCD(int a,int b){
		if(a>0 && b>0){
			a=a%b;
			GCD(b,a);
		}
		else {
			System.out.println(a);
			return;
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,gcd=2;
		a=scan.nextInt();
		b=scan.nextInt();
		if(a>=b){
			GCD(a,b);
		}
		else{
			GCD(b,a);
		}
	}
	public static void GCD(int a,int b){
		if(a>0 && b>0){
			a=a%b;
			GCD(b,a);
		}
		else {
			System.out.println(a);
			return;
		}
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,gcd=2;
		a=scan.nextInt();
		b=scan.nextInt();
		if(a>=b){
			GCD(a,b);
		}
		else{
			GCD(b,a);
		}
	} main {
		Scanner scan = new Scanner(System.in);
		int a,b,gcd=2;
		a=scan.nextInt();
		b=scan.nextInt();
		if(a>=b){
			GCD(a,b);
		}
		else{
			GCD(b,a);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a a b b gcd=2; gcd 2 a=scan.nextInt() a scan.nextInt() scan.nextInt scan b=scan.nextInt() b scan.nextInt() scan.nextInt scan if(a>=b){
			GCD(a,b);
		}
		else{
			GCD(b,a);
		} a>=b a b {
			GCD(a,b);
		} GCD(a,b) GCD a b {
			GCD(b,a);
		} GCD(b,a) GCD b a String[] args args public static void GCD(int a,int b){
		if(a>0 && b>0){
			a=a%b;
			GCD(b,a);
		}
		else {
			System.out.println(a);
			return;
		}
	} GCD {
		if(a>0 && b>0){
			a=a%b;
			GCD(b,a);
		}
		else {
			System.out.println(a);
			return;
		}
	} if(a>0 && b>0){
			a=a%b;
			GCD(b,a);
		}
		else {
			System.out.println(a);
			return;
		} a>0 && b>0 a>0 a 0 b>0 b 0 {
			a=a%b;
			GCD(b,a);
		} a=a%b a a%b a b GCD(b,a) GCD b a {
			System.out.println(a);
			return;
		} System.out.println(a) System.out.println System.out System System.out a return; int a a int b b public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,gcd=2;
		a=scan.nextInt();
		b=scan.nextInt();
		if(a>=b){
			GCD(a,b);
		}
		else{
			GCD(b,a);
		}
	}
	public static void GCD(int a,int b){
		if(a>0 && b>0){
			a=a%b;
			GCD(b,a);
		}
		else {
			System.out.println(a);
			return;
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,gcd=2;
		a=scan.nextInt();
		b=scan.nextInt();
		if(a>=b){
			GCD(a,b);
		}
		else{
			GCD(b,a);
		}
	}
	public static void GCD(int a,int b){
		if(a>0 && b>0){
			a=a%b;
			GCD(b,a);
		}
		else {
			System.out.println(a);
			return;
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,gcd=2;
		a=scan.nextInt();
		b=scan.nextInt();
		if(a>=b){
			GCD(a,b);
		}
		else{
			GCD(b,a);
		}
	}
	public static void GCD(int a,int b){
		if(a>0 && b>0){
			a=a%b;
			GCD(b,a);
		}
		else {
			System.out.println(a);
			return;
		}
	}
}
