
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		solve();
	}

	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x<y){
			int tmp = x;
			x = y;
			y = tmp;
		}

		while(true){
			int a = x % y;
			if(a==0){
				break;
			}
			x = y;
			y = a;
		}

		System.out.println(y);
	}
}

 import java.io.*; io.* java import java.util.*; util.* java class Main{
	public static void main(String[] args){
		solve();
	}

	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x<y){
			int tmp = x;
			x = y;
			y = tmp;
		}

		while(true){
			int a = x % y;
			if(a==0){
				break;
			}
			x = y;
			y = a;
		}

		System.out.println(y);
	}
} Main public static void main(String[] args){
		solve();
	} main {
		solve();
	} solve() solve String[] args args public static void solve(){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x<y){
			int tmp = x;
			x = y;
			y = tmp;
		}

		while(true){
			int a = x % y;
			if(a==0){
				break;
			}
			x = y;
			y = a;
		}

		System.out.println(y);
	} solve {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x<y){
			int tmp = x;
			x = y;
			y = tmp;
		}

		while(true){
			int a = x % y;
			if(a==0){
				break;
			}
			x = y;
			y = a;
		}

		System.out.println(y);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc 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 while(true){
			int a = x % y;
			if(a==0){
				break;
			}
			x = y;
			y = a;
		} true {
			int a = x % y;
			if(a==0){
				break;
			}
			x = y;
			y = a;
		} int a = x % y; a x % y x y if(a==0){
				break;
			} a==0 a 0 {
				break;
			} break; x = y x y y = a y a System.out.println(y) System.out.println System.out System System.out y

import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		solve();
	}

	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x<y){
			int tmp = x;
			x = y;
			y = tmp;
		}

		while(true){
			int a = x % y;
			if(a==0){
				break;
			}
			x = y;
			y = a;
		}

		System.out.println(y);
	}
}


