import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		StringTokenizer stk=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(stk.nextToken());
		int b=Integer.parseInt((String)stk.nextElement());
		System.out.println(yakusuu(a,b));
	}
	static int yakusuu(int a,int b){
		if(a<b){int tmp=a;
			a=b;
			b=tmp;}
		while(a%b!=0){			
			int l=a%b;
			a=b;b=l;}
		return b;
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.FileNotFoundException; FileNotFoundException java.io import java.io.FileReader; FileReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		StringTokenizer stk=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(stk.nextToken());
		int b=Integer.parseInt((String)stk.nextElement());
		System.out.println(yakusuu(a,b));
	}
	static int yakusuu(int a,int b){
		if(a<b){int tmp=a;
			a=b;
			b=tmp;}
		while(a%b!=0){			
			int l=a%b;
			a=b;b=l;}
		return b;
	}

} Main public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		StringTokenizer stk=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(stk.nextToken());
		int b=Integer.parseInt((String)stk.nextElement());
		System.out.println(yakusuu(a,b));
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		StringTokenizer stk=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(stk.nextToken());
		int b=Integer.parseInt((String)stk.nextElement());
		System.out.println(yakusuu(a,b));
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer stk=new StringTokenizer(br.readLine()); stk new StringTokenizer(br.readLine()) int a=Integer.parseInt(stk.nextToken()); a Integer.parseInt(stk.nextToken()) Integer.parseInt Integer stk.nextToken() stk.nextToken stk int b=Integer.parseInt((String)stk.nextElement()); b Integer.parseInt((String)stk.nextElement()) Integer.parseInt Integer (String)stk.nextElement() stk.nextElement stk System.out.println(yakusuu(a,b)) System.out.println System.out System System.out yakusuu(a,b) yakusuu a b String[] args args static int yakusuu(int a,int b){
		if(a<b){int tmp=a;
			a=b;
			b=tmp;}
		while(a%b!=0){			
			int l=a%b;
			a=b;b=l;}
		return b;
	} yakusuu {
		if(a<b){int tmp=a;
			a=b;
			b=tmp;}
		while(a%b!=0){			
			int l=a%b;
			a=b;b=l;}
		return b;
	} if(a<b){int tmp=a;
			a=b;
			b=tmp;} a<b a b {int tmp=a;
			a=b;
			b=tmp;} int tmp=a; tmp a a=b a b b=tmp b tmp while(a%b!=0){			
			int l=a%b;
			a=b;b=l;} a%b!=0 a%b a b 0 {			
			int l=a%b;
			a=b;b=l;} int l=a%b; l a%b a b a=b a b b=l b l return b; b int a a int b b public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		StringTokenizer stk=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(stk.nextToken());
		int b=Integer.parseInt((String)stk.nextElement());
		System.out.println(yakusuu(a,b));
	}
	static int yakusuu(int a,int b){
		if(a<b){int tmp=a;
			a=b;
			b=tmp;}
		while(a%b!=0){			
			int l=a%b;
			a=b;b=l;}
		return b;
	}

} public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		StringTokenizer stk=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(stk.nextToken());
		int b=Integer.parseInt((String)stk.nextElement());
		System.out.println(yakusuu(a,b));
	}
	static int yakusuu(int a,int b){
		if(a<b){int tmp=a;
			a=b;
			b=tmp;}
		while(a%b!=0){			
			int l=a%b;
			a=b;b=l;}
		return b;
	}

} Main
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		StringTokenizer stk=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(stk.nextToken());
		int b=Integer.parseInt((String)stk.nextElement());
		System.out.println(yakusuu(a,b));
	}
	static int yakusuu(int a,int b){
		if(a<b){int tmp=a;
			a=b;
			b=tmp;}
		while(a%b!=0){			
			int l=a%b;
			a=b;b=l;}
		return b;
	}

}