import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
	int i = 0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	String str_A = br.readLine();

	int[] A;
	A = new int[2];
	
	Scanner s = new Scanner(str_A).useDelimiter("\\s* \\s*");
	
	while(s.hasNext()){
	    A[i] = s.nextInt();
	    i++;
	}
	
	while(Math.min(A[0],A[1]) != 0){
	    int x,y;
	    x = Math.min(A[0],A[1]);
	    y = Math.max(A[0],A[1]) % x;
	    A[0] = x;
	    A[1] = y;
	}
	System.out.println(Math.max(A[0],A[1]));
	return ;
    }
}

	
 import java.io.*; io.* java import java.util.*; util.* java class Main{
    public static void main(String[] args) throws Exception{
	int i = 0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	String str_A = br.readLine();

	int[] A;
	A = new int[2];
	
	Scanner s = new Scanner(str_A).useDelimiter("\\s* \\s*");
	
	while(s.hasNext()){
	    A[i] = s.nextInt();
	    i++;
	}
	
	while(Math.min(A[0],A[1]) != 0){
	    int x,y;
	    x = Math.min(A[0],A[1]);
	    y = Math.max(A[0],A[1]) % x;
	    A[0] = x;
	    A[1] = y;
	}
	System.out.println(Math.max(A[0],A[1]));
	return ;
    }
} Main public static void main(String[] args) throws Exception{
	int i = 0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	String str_A = br.readLine();

	int[] A;
	A = new int[2];
	
	Scanner s = new Scanner(str_A).useDelimiter("\\s* \\s*");
	
	while(s.hasNext()){
	    A[i] = s.nextInt();
	    i++;
	}
	
	while(Math.min(A[0],A[1]) != 0){
	    int x,y;
	    x = Math.min(A[0],A[1]);
	    y = Math.max(A[0],A[1]) % x;
	    A[0] = x;
	    A[1] = y;
	}
	System.out.println(Math.max(A[0],A[1]));
	return ;
    } main {
	int i = 0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	String str_A = br.readLine();

	int[] A;
	A = new int[2];
	
	Scanner s = new Scanner(str_A).useDelimiter("\\s* \\s*");
	
	while(s.hasNext()){
	    A[i] = s.nextInt();
	    i++;
	}
	
	while(Math.min(A[0],A[1]) != 0){
	    int x,y;
	    x = Math.min(A[0],A[1]);
	    y = Math.max(A[0],A[1]) % x;
	    A[0] = x;
	    A[1] = y;
	}
	System.out.println(Math.max(A[0],A[1]));
	return ;
    } int i = 0; i 0 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str_A = br.readLine(); str_A br.readLine() br.readLine br int[] A; A A = new int[2] A new int[2] 2 Scanner s = new Scanner(str_A).useDelimiter("\\s* \\s*"); s new Scanner(str_A).useDelimiter("\\s* \\s*") new Scanner(str_A).useDelimiter new Scanner(str_A) "\\s* \\s*" while(s.hasNext()){
	    A[i] = s.nextInt();
	    i++;
	} s.hasNext() s.hasNext s {
	    A[i] = s.nextInt();
	    i++;
	} A[i] = s.nextInt() A[i] A i s.nextInt() s.nextInt s i++ i while(Math.min(A[0],A[1]) != 0){
	    int x,y;
	    x = Math.min(A[0],A[1]);
	    y = Math.max(A[0],A[1]) % x;
	    A[0] = x;
	    A[1] = y;
	} Math.min(A[0],A[1]) != 0 Math.min(A[0],A[1]) Math.min Math A[0] A 0 A[1] A 1 0 {
	    int x,y;
	    x = Math.min(A[0],A[1]);
	    y = Math.max(A[0],A[1]) % x;
	    A[0] = x;
	    A[1] = y;
	} int x x y; y x = Math.min(A[0],A[1]) x Math.min(A[0],A[1]) Math.min Math A[0] A 0 A[1] A 1 y = Math.max(A[0],A[1]) % x y Math.max(A[0],A[1]) % x Math.max(A[0],A[1]) Math.max Math A[0] A 0 A[1] A 1 x A[0] = x A[0] A 0 x A[1] = y A[1] A 1 y System.out.println(Math.max(A[0],A[1])) System.out.println System.out System System.out Math.max(A[0],A[1]) Math.max Math A[0] A 0 A[1] A 1 return ; String[] args args
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
	int i = 0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	String str_A = br.readLine();

	int[] A;
	A = new int[2];
	
	Scanner s = new Scanner(str_A).useDelimiter("\\s* \\s*");
	
	while(s.hasNext()){
	    A[i] = s.nextInt();
	    i++;
	}
	
	while(Math.min(A[0],A[1]) != 0){
	    int x,y;
	    x = Math.min(A[0],A[1]);
	    y = Math.max(A[0],A[1]) % x;
	    A[0] = x;
	    A[1] = y;
	}
	System.out.println(Math.max(A[0],A[1]));
	return ;
    }
}

	

