
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Created by YuyaKita on 16/07/13.
 */
public class Main {

    public static void main(String[] args){
        // write your code here
        
            Scanner scan = new Scanner(System.in);
            int x,y,temp;
            x = scan.nextInt();
            y = scan.nextInt();
            if(y>x){
                temp = x;
                x=y;
                y=temp;
            }
            while(y!=0){
                temp = y;
                y = x%y;
                x = temp;
            };
            System.out.println(x);


    }
} import java.io.File; File java.io import java.io.FileNotFoundException; FileNotFoundException java.io import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args){
        // write your code here
        
            Scanner scan = new Scanner(System.in);
            int x,y,temp;
            x = scan.nextInt();
            y = scan.nextInt();
            if(y>x){
                temp = x;
                x=y;
                y=temp;
            }
            while(y!=0){
                temp = y;
                y = x%y;
                x = temp;
            };
            System.out.println(x);


    }
} Main public static void main(String[] args){
        // write your code here
        
            Scanner scan = new Scanner(System.in);
            int x,y,temp;
            x = scan.nextInt();
            y = scan.nextInt();
            if(y>x){
                temp = x;
                x=y;
                y=temp;
            }
            while(y!=0){
                temp = y;
                y = x%y;
                x = temp;
            };
            System.out.println(x);


    } main {
        // write your code here
        
            Scanner scan = new Scanner(System.in);
            int x,y,temp;
            x = scan.nextInt();
            y = scan.nextInt();
            if(y>x){
                temp = x;
                x=y;
                y=temp;
            }
            while(y!=0){
                temp = y;
                y = x%y;
                x = temp;
            };
            System.out.println(x);


    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x x y y temp; temp x = scan.nextInt() x scan.nextInt() scan.nextInt scan y = scan.nextInt() y scan.nextInt() scan.nextInt scan if(y>x){
                temp = x;
                x=y;
                y=temp;
            } y>x y x {
                temp = x;
                x=y;
                y=temp;
            } temp = x temp x x=y x y y=temp y temp while(y!=0){
                temp = y;
                y = x%y;
                x = temp;
            } y!=0 y 0 {
                temp = y;
                y = x%y;
                x = temp;
            } temp = y temp y y = x%y y x%y x y x = temp x temp System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {

    public static void main(String[] args){
        // write your code here
        
            Scanner scan = new Scanner(System.in);
            int x,y,temp;
            x = scan.nextInt();
            y = scan.nextInt();
            if(y>x){
                temp = x;
                x=y;
                y=temp;
            }
            while(y!=0){
                temp = y;
                y = x%y;
                x = temp;
            };
            System.out.println(x);


    }
} public class Main {

    public static void main(String[] args){
        // write your code here
        
            Scanner scan = new Scanner(System.in);
            int x,y,temp;
            x = scan.nextInt();
            y = scan.nextInt();
            if(y>x){
                temp = x;
                x=y;
                y=temp;
            }
            while(y!=0){
                temp = y;
                y = x%y;
                x = temp;
            };
            System.out.println(x);


    }
} Main

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Created by YuyaKita on 16/07/13.
 */
public class Main {

    public static void main(String[] args){
        // write your code here
        
            Scanner scan = new Scanner(System.in);
            int x,y,temp;
            x = scan.nextInt();
            y = scan.nextInt();
            if(y>x){
                temp = x;
                x=y;
                y=temp;
            }
            while(y!=0){
                temp = y;
                y = x%y;
                x = temp;
            };
            System.out.println(x);


    }
}