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

public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

 
    private void cal() throws IOException 
    {
	st = new StringTokenizer(br.readLine());
	int a = Integer.parseInt(st.nextToken());
	int b = Integer.parseInt(st.nextToken());

	int x, y;
	if ( a > b ) {
	    x = a; y = b;
	} else {
	    x = b; y = a;
	}

	while( y > 0 ) {
	    int temp = x;
	    x = y;
	    y = temp % y;
	}

	System.out.println(x);

	
	

    }

} import java.io.*; io.* java import java.util.*; util.* java public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

 
    private void cal() throws IOException 
    {
	st = new StringTokenizer(br.readLine());
	int a = Integer.parseInt(st.nextToken());
	int b = Integer.parseInt(st.nextToken());

	int x, y;
	if ( a > b ) {
	    x = a; y = b;
	} else {
	    x = b; y = a;
	}

	while( y > 0 ) {
	    int temp = x;
	    x = y;
	    y = temp % y;
	}

	System.out.println(x);

	
	

    }

} Main private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) private static StringTokenizer st; st public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    } main {
	new Main().cal();
    } new Main().cal() new Main().cal new Main() String [] args args private void cal() throws IOException 
    {
	st = new StringTokenizer(br.readLine());
	int a = Integer.parseInt(st.nextToken());
	int b = Integer.parseInt(st.nextToken());

	int x, y;
	if ( a > b ) {
	    x = a; y = b;
	} else {
	    x = b; y = a;
	}

	while( y > 0 ) {
	    int temp = x;
	    x = y;
	    y = temp % y;
	}

	System.out.println(x);

	
	

    } cal {
	st = new StringTokenizer(br.readLine());
	int a = Integer.parseInt(st.nextToken());
	int b = Integer.parseInt(st.nextToken());

	int x, y;
	if ( a > b ) {
	    x = a; y = b;
	} else {
	    x = b; y = a;
	}

	while( y > 0 ) {
	    int temp = x;
	    x = y;
	    y = temp % y;
	}

	System.out.println(x);

	
	

    } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) int a = Integer.parseInt(st.nextToken()); a Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int b = Integer.parseInt(st.nextToken()); b Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int x x y; y if ( a > b ) {
	    x = a; y = b;
	} else {
	    x = b; y = a;
	} a > b a b {
	    x = a; y = b;
	} x = a x a y = b y b {
	    x = b; y = a;
	} x = b x b y = a y a while( y > 0 ) {
	    int temp = x;
	    x = y;
	    y = temp % y;
	} y > 0 y 0 {
	    int temp = x;
	    x = y;
	    y = temp % y;
	} int temp = x; temp x x = y x y y = temp % y y temp % y temp y System.out.println(x) System.out.println System.out System System.out x public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

 
    private void cal() throws IOException 
    {
	st = new StringTokenizer(br.readLine());
	int a = Integer.parseInt(st.nextToken());
	int b = Integer.parseInt(st.nextToken());

	int x, y;
	if ( a > b ) {
	    x = a; y = b;
	} else {
	    x = b; y = a;
	}

	while( y > 0 ) {
	    int temp = x;
	    x = y;
	    y = temp % y;
	}

	System.out.println(x);

	
	

    }

} public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

 
    private void cal() throws IOException 
    {
	st = new StringTokenizer(br.readLine());
	int a = Integer.parseInt(st.nextToken());
	int b = Integer.parseInt(st.nextToken());

	int x, y;
	if ( a > b ) {
	    x = a; y = b;
	} else {
	    x = b; y = a;
	}

	while( y > 0 ) {
	    int temp = x;
	    x = y;
	    y = temp % y;
	}

	System.out.println(x);

	
	

    }

} Main
import java.io.*;
import java.util.*;

public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

 
    private void cal() throws IOException 
    {
	st = new StringTokenizer(br.readLine());
	int a = Integer.parseInt(st.nextToken());
	int b = Integer.parseInt(st.nextToken());

	int x, y;
	if ( a > b ) {
	    x = a; y = b;
	} else {
	    x = b; y = a;
	}

	while( y > 0 ) {
	    int temp = x;
	    x = y;
	    y = temp % y;
	}

	System.out.println(x);

	
	

    }

}