import java.util.*;
public class Main {
	static Scanner sc = new Scanner (System.in);
	public static void main (String[] args) {
		Main calc = new Main(); 
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(calc.GCF(a, b));
	}	
	public long GCF(long a, long b) {
	    if (b == 0) return a;
	    else return (GCF (b, a % b));
	}
} import java.util.*; util.* java public class Main {
	static Scanner sc = new Scanner (System.in);
	public static void main (String[] args) {
		Main calc = new Main(); 
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(calc.GCF(a, b));
	}	
	public long GCF(long a, long b) {
	    if (b == 0) return a;
	    else return (GCF (b, a % b));
	}
} Main static Scanner sc = new Scanner (System.in); sc new Scanner (System.in) public static void main (String[] args) {
		Main calc = new Main(); 
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(calc.GCF(a, b));
	} main {
		Main calc = new Main(); 
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(calc.GCF(a, b));
	} Main calc = new Main(); calc new Main() long a = sc.nextLong(); a sc.nextLong() sc.nextLong sc long b = sc.nextLong(); b sc.nextLong() sc.nextLong sc System.out.println(calc.GCF(a, b)) System.out.println System.out System System.out calc.GCF(a, b) calc.GCF calc a b String[] args args public long GCF(long a, long b) {
	    if (b == 0) return a;
	    else return (GCF (b, a % b));
	} GCF {
	    if (b == 0) return a;
	    else return (GCF (b, a % b));
	} if (b == 0) return a;
	    else return (GCF (b, a % b)); b == 0 b 0 return a; a return (GCF (b, a % b)); (GCF (b, a % b)) GCF b a % b a b long a a long b b public class Main {
	static Scanner sc = new Scanner (System.in);
	public static void main (String[] args) {
		Main calc = new Main(); 
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(calc.GCF(a, b));
	}	
	public long GCF(long a, long b) {
	    if (b == 0) return a;
	    else return (GCF (b, a % b));
	}
} public class Main {
	static Scanner sc = new Scanner (System.in);
	public static void main (String[] args) {
		Main calc = new Main(); 
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(calc.GCF(a, b));
	}	
	public long GCF(long a, long b) {
	    if (b == 0) return a;
	    else return (GCF (b, a % b));
	}
} Main
import java.util.*;
public class Main {
	static Scanner sc = new Scanner (System.in);
	public static void main (String[] args) {
		Main calc = new Main(); 
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(calc.GCF(a, b));
	}	
	public long GCF(long a, long b) {
	    if (b == 0) return a;
	    else return (GCF (b, a % b));
	}
}