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

class Main{
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

//		 int n = Integer.parseInt(in.readLine());
		
		 String[] xy = in.readLine().split(" ");

		 int x=Integer.parseInt(xy[0]);
		 int y=Integer.parseInt(xy[1]);
		 

		 
		 int tmp;
		 while(y!=0){
			 
			 tmp=x%y;
			 x=y;
			 y=tmp;
			 
		 }
		 
		 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 class Main{
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

//		 int n = Integer.parseInt(in.readLine());
		
		 String[] xy = in.readLine().split(" ");

		 int x=Integer.parseInt(xy[0]);
		 int y=Integer.parseInt(xy[1]);
		 

		 
		 int tmp;
		 while(y!=0){
			 
			 tmp=x%y;
			 x=y;
			 y=tmp;
			 
		 }
		 
		 System.out.println(x);
		
	}
} Main public static void main(String[] args) throws IOException {
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

//		 int n = Integer.parseInt(in.readLine());
		
		 String[] xy = in.readLine().split(" ");

		 int x=Integer.parseInt(xy[0]);
		 int y=Integer.parseInt(xy[1]);
		 

		 
		 int tmp;
		 while(y!=0){
			 
			 tmp=x%y;
			 x=y;
			 y=tmp;
			 
		 }
		 
		 System.out.println(x);
		
	} main {
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

//		 int n = Integer.parseInt(in.readLine());
		
		 String[] xy = in.readLine().split(" ");

		 int x=Integer.parseInt(xy[0]);
		 int y=Integer.parseInt(xy[1]);
		 

		 
		 int tmp;
		 while(y!=0){
			 
			 tmp=x%y;
			 x=y;
			 y=tmp;
			 
		 }
		 
		 System.out.println(x);
		
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String[] xy = in.readLine().split(" "); xy in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int x=Integer.parseInt(xy[0]); x Integer.parseInt(xy[0]) Integer.parseInt Integer xy[0] xy 0 int y=Integer.parseInt(xy[1]); y Integer.parseInt(xy[1]) Integer.parseInt Integer xy[1] xy 1 int tmp; tmp while(y!=0){
			 
			 tmp=x%y;
			 x=y;
			 y=tmp;
			 
		 } y!=0 y 0 {
			 
			 tmp=x%y;
			 x=y;
			 y=tmp;
			 
		 } tmp=x%y tmp x%y x y x=y x y y=tmp y tmp System.out.println(x) System.out.println System.out System System.out x String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

//		 int n = Integer.parseInt(in.readLine());
		
		 String[] xy = in.readLine().split(" ");

		 int x=Integer.parseInt(xy[0]);
		 int y=Integer.parseInt(xy[1]);
		 

		 
		 int tmp;
		 while(y!=0){
			 
			 tmp=x%y;
			 x=y;
			 y=tmp;
			 
		 }
		 
		 System.out.println(x);
		
	}
}