import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

class Test{
    long r;
    long gcd(long a, long b){
        while(true){
            if(a>b){
                a=a-b;
            }else{
                break;
            }
        }
        if(b%a==0){
            r=a;
        }else{
            gcd(b,a);
        }
        return r;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } catch (Exception e) {
            System.out.println(e);
        }
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } catch (Exception e) {
            System.out.println(e);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } catch (Exception e) {
            System.out.println(e);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } catch (Exception e) {
            System.out.println(e);
        } catch (Exception e) {
            System.out.println(e);
        } Exception e {
            System.out.println(e);
        } System.out.println(e) System.out.println System.out System System.out e {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } long a a b b gcd; gcd String line = br.readLine(); line br.readLine() br.readLine br StringTokenizer st; st st=new StringTokenizer(line) st new StringTokenizer(line) a=Long.parseLong(st.nextToken()) a Long.parseLong(st.nextToken()) Long.parseLong Long st.nextToken() st.nextToken st b=Long.parseLong(st.nextToken()) b Long.parseLong(st.nextToken()) Long.parseLong Long st.nextToken() st.nextToken st Test t = new Test(); t new Test() gcd=t.gcd(a,b) gcd t.gcd(a,b) t.gcd t a b System.out.println(gcd) System.out.println System.out System System.out gcd String[] args args class Test{
    long r;
    long gcd(long a, long b){
        while(true){
            if(a>b){
                a=a-b;
            }else{
                break;
            }
        }
        if(b%a==0){
            r=a;
        }else{
            gcd(b,a);
        }
        return r;
    }
} Test long r; r long gcd(long a, long b){
        while(true){
            if(a>b){
                a=a-b;
            }else{
                break;
            }
        }
        if(b%a==0){
            r=a;
        }else{
            gcd(b,a);
        }
        return r;
    } gcd {
        while(true){
            if(a>b){
                a=a-b;
            }else{
                break;
            }
        }
        if(b%a==0){
            r=a;
        }else{
            gcd(b,a);
        }
        return r;
    } while(true){
            if(a>b){
                a=a-b;
            }else{
                break;
            }
        } true {
            if(a>b){
                a=a-b;
            }else{
                break;
            }
        } if(a>b){
                a=a-b;
            }else{
                break;
            } a>b a b {
                a=a-b;
            } a=a-b a a-b a b {
                break;
            } break; if(b%a==0){
            r=a;
        }else{
            gcd(b,a);
        } b%a==0 b%a b a 0 {
            r=a;
        } r=a r a {
            gcd(b,a);
        } gcd(b,a) gcd b a return r; r long a a long b b public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } catch (Exception e) {
            System.out.println(e);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } catch (Exception e) {
            System.out.println(e);
        }
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            st=new StringTokenizer(line);
            a=Long.parseLong(st.nextToken());
            b=Long.parseLong(st.nextToken());
            Test t = new Test();
            gcd=t.gcd(a,b);
            System.out.println(gcd);
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

class Test{
    long r;
    long gcd(long a, long b){
        while(true){
            if(a>b){
                a=a-b;
            }else{
                break;
            }
        }
        if(b%a==0){
            r=a;
        }else{
            gcd(b,a);
        }
        return r;
    }
}