import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = (br.readLine()).split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int x,y;
		if (a>b) {
			x = a;
			y = b;
		}else{
			x = b;
			y = a;
		}
		int work;
		while(x%y != 0) {
			work = y;
			y = x%y;
			x = work;
		}
		System.out.println(y);
	}
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = (br.readLine()).split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int x,y;
		if (a>b) {
			x = a;
			y = b;
		}else{
			x = b;
			y = a;
		}
		int work;
		while(x%y != 0) {
			work = y;
			y = x%y;
			x = work;
		}
		System.out.println(y);
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = (br.readLine()).split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int x,y;
		if (a>b) {
			x = a;
			y = b;
		}else{
			x = b;
			y = a;
		}
		int work;
		while(x%y != 0) {
			work = y;
			y = x%y;
			x = work;
		}
		System.out.println(y);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = (br.readLine()).split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int x,y;
		if (a>b) {
			x = a;
			y = b;
		}else{
			x = b;
			y = a;
		}
		int work;
		while(x%y != 0) {
			work = y;
			y = x%y;
			x = work;
		}
		System.out.println(y);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] line = (br.readLine()).split(" "); line (br.readLine()).split(" ") (br.readLine()).split (br.readLine()) br.readLine br " " int a = Integer.parseInt(line[0]); a Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int b = Integer.parseInt(line[1]); b Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 int x x y; y if (a>b) {
			x = a;
			y = b;
		}else{
			x = b;
			y = a;
		} a>b a b {
			x = a;
			y = b;
		} x = a x a y = b y b {
			x = b;
			y = a;
		} x = b x b y = a y a int work; work while(x%y != 0) {
			work = y;
			y = x%y;
			x = work;
		} x%y != 0 x%y x y 0 {
			work = y;
			y = x%y;
			x = work;
		} work = y work y y = x%y y x%y x y x = work x work System.out.println(y) System.out.println System.out System System.out y String[] args args
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = (br.readLine()).split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int x,y;
		if (a>b) {
			x = a;
			y = b;
		}else{
			x = b;
			y = a;
		}
		int work;
		while(x%y != 0) {
			work = y;
			y = x%y;
			x = work;
		}
		System.out.println(y);
	}
}