import java.io.*;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		}
	}
	
	static long GCD(long[] ab){
		long k;
		while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		}
	}

} import java.io.*; io.* java public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		}
	}
	
	static long GCD(long[] ab){
		long k;
		while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		}
	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		}
	} main {
		// TODO ?????????????????????????????????????????????
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		}
	} try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		} catch(IOException e){
			System.out.println("IOException");
		} IOException e {
			System.out.println("IOException");
		} System.out.println("IOException") System.out.println System.out System System.out "IOException" {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " long a = Long.parseLong(str[0]); a Long.parseLong(str[0]) Long.parseLong Long str[0] str 0 long b = Long.parseLong(str[1]); b Long.parseLong(str[1]) Long.parseLong Long str[1] str 1 long[] ab = new long[2]; ab new long[2] 2 ab[0] = Math.min(a, b) ab[0] ab 0 Math.min(a, b) Math.min Math a b ab[1] = Math.max(a, b) ab[1] ab 1 Math.max(a, b) Math.max Math a b System.out.println(GCD(ab)) System.out.println System.out System System.out GCD(ab) GCD ab String[] args args static long GCD(long[] ab){
		long k;
		while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		}
	} GCD {
		long k;
		while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		}
	} long k; k while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		} true {
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		} k = ab[1]%ab[0] k ab[1]%ab[0] ab[1] ab 1 ab[0] ab 0 if (k==0){
				return ab[0];
			} k==0 k 0 {
				return ab[0];
			} return ab[0]; ab[0] ab 0 ab[1] = ab[0] ab[1] ab 1 ab[0] ab 0 ab[0] = k ab[0] ab 0 k long[] ab ab public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		}
	}
	
	static long GCD(long[] ab){
		long k;
		while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		}
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		}
	}
	
	static long GCD(long[] ab){
		long k;
		while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		}
	}

} Main
import java.io.*;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		}
	}
	
	static long GCD(long[] ab){
		long k;
		while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		}
	}

}