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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        long a=Long.parseLong(lines[0]);
        long b=Long.parseLong(lines[1]);
        System.out.println(gcd(a,b));
    }
    static long gcd(long x,long y){
       if(x<y){
           long temp=x;
           x=y;
           y=temp;
       }
       if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       }
    }
}
       import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        long a=Long.parseLong(lines[0]);
        long b=Long.parseLong(lines[1]);
        System.out.println(gcd(a,b));
    }
    static long gcd(long x,long y){
       if(x<y){
           long temp=x;
           x=y;
           y=temp;
       }
       if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       }
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        long a=Long.parseLong(lines[0]);
        long b=Long.parseLong(lines[1]);
        System.out.println(gcd(a,b));
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        long a=Long.parseLong(lines[0]);
        long b=Long.parseLong(lines[1]);
        System.out.println(gcd(a,b));
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] lines = br.readLine().split(" "); lines br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " long a=Long.parseLong(lines[0]); a Long.parseLong(lines[0]) Long.parseLong Long lines[0] lines 0 long b=Long.parseLong(lines[1]); b Long.parseLong(lines[1]) Long.parseLong Long lines[1] lines 1 System.out.println(gcd(a,b)) System.out.println System.out System System.out gcd(a,b) gcd a b String[] args args static long gcd(long x,long y){
       if(x<y){
           long temp=x;
           x=y;
           y=temp;
       }
       if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       }
    } gcd {
       if(x<y){
           long temp=x;
           x=y;
           y=temp;
       }
       if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       }
    } if(x<y){
           long temp=x;
           x=y;
           y=temp;
       } x<y x y {
           long temp=x;
           x=y;
           y=temp;
       } long temp=x; temp x x=y x y y=temp y temp if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       } y >0 y 0 {
           return gcd(y,x%y);
       } return gcd(y,x%y); gcd(y,x%y) gcd y x%y x y {
           return x;
       } return x; x long x x long y y public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        long a=Long.parseLong(lines[0]);
        long b=Long.parseLong(lines[1]);
        System.out.println(gcd(a,b));
    }
    static long gcd(long x,long y){
       if(x<y){
           long temp=x;
           x=y;
           y=temp;
       }
       if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       }
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        long a=Long.parseLong(lines[0]);
        long b=Long.parseLong(lines[1]);
        System.out.println(gcd(a,b));
    }
    static long gcd(long x,long y){
       if(x<y){
           long temp=x;
           x=y;
           y=temp;
       }
       if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        long a=Long.parseLong(lines[0]);
        long b=Long.parseLong(lines[1]);
        System.out.println(gcd(a,b));
    }
    static long gcd(long x,long y){
       if(x<y){
           long temp=x;
           x=y;
           y=temp;
       }
       if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       }
    }
}
      