import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		
		while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		}		
		
		System.out.println(x);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		
		while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		}		
		
		System.out.println(x);
	}

} Main public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		
		while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		}		
		
		System.out.println(x);
	} main {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		
		while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		}		
		
		System.out.println(x);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] tmpArray = br.readLine().split(" "); tmpArray br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(tmpArray[0]); x Integer.parseInt(tmpArray[0]) Integer.parseInt Integer tmpArray[0] tmpArray 0 int y = Integer.parseInt(tmpArray[1]); y Integer.parseInt(tmpArray[1]) Integer.parseInt Integer tmpArray[1] tmpArray 1 while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		} x != y x y {
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		} if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			} y > x y x {
				int tmp = y;
				y = x;
				x = tmp;
			} int tmp = y; tmp y y = x y x x = tmp x tmp if(x%y == 0){
				x = y;
				break;
			} x%y == 0 x%y x y 0 {
				x = y;
				break;
			} x = y x y break; x = x%y x x%y x y System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		
		while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		}		
		
		System.out.println(x);
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		
		while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		}		
		
		System.out.println(x);
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		
		while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		}		
		
		System.out.println(x);
	}

}