import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		long numbef = scanner.nextInt();//要素数
		long numaft = scanner.nextInt();//要素数
		
		gcd_euclid(numbef, numaft);
		
		scanner.close();
	}
	
	public static void gcd_euclid(long numbef, long numaft) {
		  long sub;
		  while (0 != numaft) {
		  	//ユークリッドの互除法
		    sub = numbef % numaft; 
		  	numbef = numaft; 
		  	numaft = sub;
		  }
		  System.out.println(numbef);
		}
}

 import java.util.Scanner; Scanner java.util class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		long numbef = scanner.nextInt();//要素数
		long numaft = scanner.nextInt();//要素数
		
		gcd_euclid(numbef, numaft);
		
		scanner.close();
	}
	
	public static void gcd_euclid(long numbef, long numaft) {
		  long sub;
		  while (0 != numaft) {
		  	//ユークリッドの互除法
		    sub = numbef % numaft; 
		  	numbef = numaft; 
		  	numaft = sub;
		  }
		  System.out.println(numbef);
		}
} Main public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		long numbef = scanner.nextInt();//要素数
		long numaft = scanner.nextInt();//要素数
		
		gcd_euclid(numbef, numaft);
		
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		long numbef = scanner.nextInt();//要素数
		long numaft = scanner.nextInt();//要素数
		
		gcd_euclid(numbef, numaft);
		
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) long numbef = scanner.nextInt(); numbef scanner.nextInt() scanner.nextInt scanner long numaft = scanner.nextInt(); numaft scanner.nextInt() scanner.nextInt scanner gcd_euclid(numbef, numaft) gcd_euclid numbef numaft scanner.close() scanner.close scanner String args[] args public static void gcd_euclid(long numbef, long numaft) {
		  long sub;
		  while (0 != numaft) {
		  	//ユークリッドの互除法
		    sub = numbef % numaft; 
		  	numbef = numaft; 
		  	numaft = sub;
		  }
		  System.out.println(numbef);
		} gcd_euclid {
		  long sub;
		  while (0 != numaft) {
		  	//ユークリッドの互除法
		    sub = numbef % numaft; 
		  	numbef = numaft; 
		  	numaft = sub;
		  }
		  System.out.println(numbef);
		} long sub; sub while (0 != numaft) {
		  	//ユークリッドの互除法
		    sub = numbef % numaft; 
		  	numbef = numaft; 
		  	numaft = sub;
		  } 0 != numaft 0 numaft {
		  	//ユークリッドの互除法
		    sub = numbef % numaft; 
		  	numbef = numaft; 
		  	numaft = sub;
		  } sub = numbef % numaft sub numbef % numaft numbef numaft numbef = numaft numbef numaft numaft = sub numaft sub System.out.println(numbef) System.out.println System.out System System.out numbef long numbef numbef long numaft numaft
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		long numbef = scanner.nextInt();//要素数
		long numaft = scanner.nextInt();//要素数
		
		gcd_euclid(numbef, numaft);
		
		scanner.close();
	}
	
	public static void gcd_euclid(long numbef, long numaft) {
		  long sub;
		  while (0 != numaft) {
		  	//ユークリッドの互除法
		    sub = numbef % numaft; 
		  	numbef = numaft; 
		  	numaft = sub;
		  }
		  System.out.println(numbef);
		}
}


