


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

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

   String[] string =  br.readLine().split(" ");

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

   int tmp;

   if(x < y){

	   tmp = x;
	   x = y;
	   y = tmp;

   }

   int r = x % y;
   while(r!=0){
     x = y;
     y = r;
	 r = x % y;
   }

   System.out.println(y);

 }
} 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 br = new BufferedReader(new InputStreamReader(System.in));

   String[] string =  br.readLine().split(" ");

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

   int tmp;

   if(x < y){

	   tmp = x;
	   x = y;
	   y = tmp;

   }

   int r = x % y;
   while(r!=0){
     x = y;
     y = r;
	 r = x % y;
   }

   System.out.println(y);

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

   String[] string =  br.readLine().split(" ");

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

   int tmp;

   if(x < y){

	   tmp = x;
	   x = y;
	   y = tmp;

   }

   int r = x % y;
   while(r!=0){
     x = y;
     y = r;
	 r = x % y;
   }

   System.out.println(y);

 } main {
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

   String[] string =  br.readLine().split(" ");

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

   int tmp;

   if(x < y){

	   tmp = x;
	   x = y;
	   y = tmp;

   }

   int r = x % y;
   while(r!=0){
     x = y;
     y = r;
	 r = x % y;
   }

   System.out.println(y);

 } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] string =  br.readLine().split(" "); string br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt( string[0] ); x Integer.parseInt( string[0] ) Integer.parseInt Integer string[0] string 0 int y = Integer.parseInt( string[1] ); y Integer.parseInt( string[1] ) Integer.parseInt Integer string[1] string 1 int tmp; tmp if(x < y){

	   tmp = x;
	   x = y;
	   y = tmp;

   } x < y x y {

	   tmp = x;
	   x = y;
	   y = tmp;

   } tmp = x tmp x x = y x y y = tmp y tmp int r = x % y; r x % y x y while(r!=0){
     x = y;
     y = r;
	 r = x % y;
   } r!=0 r 0 {
     x = y;
     y = r;
	 r = x % y;
   } x = y x y y = r y r r = x % y r x % y x y System.out.println(y) System.out.println System.out System System.out y 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 br = new BufferedReader(new InputStreamReader(System.in));

   String[] string =  br.readLine().split(" ");

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

   int tmp;

   if(x < y){

	   tmp = x;
	   x = y;
	   y = tmp;

   }

   int r = x % y;
   while(r!=0){
     x = y;
     y = r;
	 r = x % y;
   }

   System.out.println(y);

 }
}