import java.io.*;
 
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            String[] nums = kb.readLine().split( " " );
            int a = Integer.parseInt( nums[0] );
            int b = Integer.parseInt( nums[1] );
            
            System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
    
	public static int gcd( int x, int y )
	{
		if( 0 == y ) {
			return x;
		} else {
			return gcd( y, x%y );
		}
	}
} import java.io.*; io.* java class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            String[] nums = kb.readLine().split( " " );
            int a = Integer.parseInt( nums[0] );
            int b = Integer.parseInt( nums[1] );
            
            System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
    
	public static int gcd( int x, int y )
	{
		if( 0 == y ) {
			return x;
		} else {
			return gcd( y, x%y );
		}
	}
} Main public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            String[] nums = kb.readLine().split( " " );
            int a = Integer.parseInt( nums[0] );
            int b = Integer.parseInt( nums[1] );
            
            System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    } main {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            String[] nums = kb.readLine().split( " " );
            int a = Integer.parseInt( nums[0] );
            int b = Integer.parseInt( nums[1] );
            
            System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    } BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) ); kb new BufferedReader( new InputStreamReader( System.in ) ) try {
            String[] nums = kb.readLine().split( " " );
            int a = Integer.parseInt( nums[0] );
            int b = Integer.parseInt( nums[1] );
            
            System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        } catch( IOException e ) {
            System.err.println( e );
        } IOException e {
            System.err.println( e );
        } System.err.println( e ) System.err.println System.err System System.err e {
            String[] nums = kb.readLine().split( " " );
            int a = Integer.parseInt( nums[0] );
            int b = Integer.parseInt( nums[1] );
            
            System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  );
             
            kb.close();
        } String[] nums = kb.readLine().split( " " ); nums kb.readLine().split( " " ) kb.readLine().split kb.readLine() kb.readLine kb " " int a = Integer.parseInt( nums[0] ); a Integer.parseInt( nums[0] ) Integer.parseInt Integer nums[0] nums 0 int b = Integer.parseInt( nums[1] ); b Integer.parseInt( nums[1] ) Integer.parseInt Integer nums[1] nums 1 System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  ) System.out.println System.out System System.out gcd( Math.max( a, b ), Math.min( a, b ) ) gcd Math.max( a, b ) Math.max Math a b Math.min( a, b ) Math.min Math a b kb.close() kb.close kb String[] args args public static int gcd( int x, int y )
	{
		if( 0 == y ) {
			return x;
		} else {
			return gcd( y, x%y );
		}
	} gcd {
		if( 0 == y ) {
			return x;
		} else {
			return gcd( y, x%y );
		}
	} if( 0 == y ) {
			return x;
		} else {
			return gcd( y, x%y );
		} 0 == y 0 y {
			return x;
		} return x; x {
			return gcd( y, x%y );
		} return gcd( y, x%y ); gcd( y, x%y ) gcd y x%y x y int x x int y y
import java.io.*;
 
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            String[] nums = kb.readLine().split( " " );
            int a = Integer.parseInt( nums[0] );
            int b = Integer.parseInt( nums[1] );
            
            System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
    
	public static int gcd( int x, int y )
	{
		if( 0 == y ) {
			return x;
		} else {
			return gcd( y, x%y );
		}
	}
}