import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
    
    static int calc(int a, int b){
        if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if(b==0){
            return a;
        }
        return calc(b, a%b);
    }
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main{
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
    
    static int calc(int a, int b){
        if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if(b==0){
            return a;
        }
        return calc(b, a%b);
    }
} Main public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        }catch(IOException e) {
            e.printStackTrace();
        } catch(IOException e) {
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        } String[] arr = br.readLine().split("\\s"); arr br.readLine().split("\\s") br.readLine().split br.readLine() br.readLine br "\\s" int[] nums = new int[arr.length]; nums new int[arr.length] arr.length arr arr.length for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            } int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
                nums[i] = Integer.parseInt(arr[i]);
            } {
                nums[i] = Integer.parseInt(arr[i]);
            } nums[i] = Integer.parseInt(arr[i]) nums[i] nums i Integer.parseInt(arr[i]) Integer.parseInt Integer arr[i] arr i System.out.println(String.valueOf(calc(nums[0], nums[1]))) System.out.println System.out System System.out String.valueOf(calc(nums[0], nums[1])) String.valueOf String calc(nums[0], nums[1]) calc nums[0] nums 0 nums[1] nums 1 String[] args args static int calc(int a, int b){
        if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if(b==0){
            return a;
        }
        return calc(b, a%b);
    } calc {
        if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if(b==0){
            return a;
        }
        return calc(b, a%b);
    } if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        } a<b a b {
            int tmp = a;
            a = b;
            b = tmp;
        } int tmp = a; tmp a a = b a b b = tmp b tmp if(b==0){
            return a;
        } b==0 b 0 {
            return a;
        } return a; a return calc(b, a%b); calc(b, a%b) calc b a%b a b int a a int b b public class Main{
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
    
    static int calc(int a, int b){
        if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if(b==0){
            return a;
        }
        return calc(b, a%b);
    }
} public class Main{
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
    
    static int calc(int a, int b){
        if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if(b==0){
            return a;
        }
        return calc(b, a%b);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            int[] nums = new int[arr.length];
            
            for(int i=0; i<arr.length; i++){
                nums[i] = Integer.parseInt(arr[i]);
            }
            
            System.out.println(String.valueOf(calc(nums[0], nums[1])));
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
    
    static int calc(int a, int b){
        if(a<b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if(b==0){
            return a;
        }
        return calc(b, a%b);
    }
}

