
import java.util.*;

class Animal
{
    String name;
    String genus;
    int region;

    public Animal(String name, String genus, int region)
    {
        this.name = name;
        this.genus = genus;
        this.region = region;
    }

    public int getRegion()
    {
        return this.region;
    }

    public String getGenus()
    {
        return this.genus;
    }

    public String getName()
    {
        return this.name;
    }
}

class Human extends Animal
{
    String sex;
    String bloodGroup;

    public Human(String sex, String bloodGroup)
    {
        super("HS", "homo", 1);
        this.sex = sex;
        this.bloodGroup = bloodGroup;
    }

    public String getSex()
    {
        return sex;
    }

    public String getBloodGroup()
    {
        return bloodGroup;
    }
}

public class Main
{

    public static Scanner in = new Scanner(System.in);

    public void print(int[] a)
    {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    }

    public int[] insert(int[] a)
    {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    }

    public int gcd(int a, int b)
    {
        if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        }
    }

    public void go()
    {
        int a = in.nextInt();
        int b = in.nextInt();

        int value = new Main().gcd(a, b);

        System.out.println(value);

    }

    public static void main(String[] args)
    {
        new Main().go();


    }
} import java.util.*; util.* java class Animal
{
    String name;
    String genus;
    int region;

    public Animal(String name, String genus, int region)
    {
        this.name = name;
        this.genus = genus;
        this.region = region;
    }

    public int getRegion()
    {
        return this.region;
    }

    public String getGenus()
    {
        return this.genus;
    }

    public String getName()
    {
        return this.name;
    }
} Animal String name; name String genus; genus int region; region public Animal(String name, String genus, int region)
    {
        this.name = name;
        this.genus = genus;
        this.region = region;
    } Animal {
        this.name = name;
        this.genus = genus;
        this.region = region;
    } this.name = name this.name this this.name name this.genus = genus this.genus this this.genus genus this.region = region this.region this this.region region String name name String genus genus int region region public int getRegion()
    {
        return this.region;
    } getRegion {
        return this.region;
    } return this.region; this.region this this.region public String getGenus()
    {
        return this.genus;
    } getGenus {
        return this.genus;
    } return this.genus; this.genus this this.genus public String getName()
    {
        return this.name;
    } getName {
        return this.name;
    } return this.name; this.name this this.name class Human extends Animal
{
    String sex;
    String bloodGroup;

    public Human(String sex, String bloodGroup)
    {
        super("HS", "homo", 1);
        this.sex = sex;
        this.bloodGroup = bloodGroup;
    }

    public String getSex()
    {
        return sex;
    }

    public String getBloodGroup()
    {
        return bloodGroup;
    }
} Human String sex; sex String bloodGroup; bloodGroup public Human(String sex, String bloodGroup)
    {
        super("HS", "homo", 1);
        this.sex = sex;
        this.bloodGroup = bloodGroup;
    } Human {
        super("HS", "homo", 1);
        this.sex = sex;
        this.bloodGroup = bloodGroup;
    } super("HS", "homo", 1) super "HS" "homo" 1 this.sex = sex this.sex this this.sex sex this.bloodGroup = bloodGroup this.bloodGroup this this.bloodGroup bloodGroup String sex sex String bloodGroup bloodGroup public String getSex()
    {
        return sex;
    } getSex {
        return sex;
    } return sex; sex public String getBloodGroup()
    {
        return bloodGroup;
    } getBloodGroup {
        return bloodGroup;
    } return bloodGroup; bloodGroup Animal public class Main
{

    public static Scanner in = new Scanner(System.in);

    public void print(int[] a)
    {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    }

    public int[] insert(int[] a)
    {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    }

    public int gcd(int a, int b)
    {
        if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        }
    }

    public void go()
    {
        int a = in.nextInt();
        int b = in.nextInt();

        int value = new Main().gcd(a, b);

        System.out.println(value);

    }

    public static void main(String[] args)
    {
        new Main().go();


    }
} Main public static Scanner in = new Scanner(System.in); in new Scanner(System.in) public void print(int[] a)
    {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    } print {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    } for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        } int i = 0; int i = 0; i 0 i <a.length-1 i a.length-1 a.length a a.length 1 i++ i++ i {
            System.out.print(a[i]+" ");
        } {
            System.out.print(a[i]+" ");
        } System.out.print(a[i]+" ") System.out.print System.out System System.out a[i]+" " a[i] a i " " System.out.println(a[a.length-1]) System.out.println System.out System System.out a[a.length-1] a a.length-1 a.length a a.length 1 int[] a a public int[] insert(int[] a)
    {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    } insert {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    } for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        } int i = 0; int i = 0; i 0 i <a.length i a.length a a.length i++ i++ i {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        } {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        } int key=a[i]; key a[i] a i int j=i-1; j i-1 i 1 while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            } j>=0 && a[j]>key j>=0 j 0 a[j]>key a[j] a j key {
                a[j+1] = a[j];
                j--;
            } a[j+1] = a[j] a[j+1] a j+1 j 1 a[j] a j j-- j a[j+1] = key a[j+1] a j+1 j 1 key new Main().print(a) new Main().print new Main() a return a; a int[] a a public int gcd(int a, int b)
    {
        if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        }
    } gcd {
        if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        }
    } if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        } b==0 b 0 {
            return a;
        } return a; a {
            return gcd(b, a%b);
        } return gcd(b, a%b); gcd(b, a%b) gcd b a%b a b int a a int b b public void go()
    {
        int a = in.nextInt();
        int b = in.nextInt();

        int value = new Main().gcd(a, b);

        System.out.println(value);

    } go {
        int a = in.nextInt();
        int b = in.nextInt();

        int value = new Main().gcd(a, b);

        System.out.println(value);

    } int a = in.nextInt(); a in.nextInt() in.nextInt in int b = in.nextInt(); b in.nextInt() in.nextInt in int value = new Main().gcd(a, b); value new Main().gcd(a, b) new Main().gcd new Main() a b System.out.println(value) System.out.println System.out System System.out value public static void main(String[] args)
    {
        new Main().go();


    } main {
        new Main().go();


    } new Main().go() new Main().go new Main() String[] args args public class Main
{

    public static Scanner in = new Scanner(System.in);

    public void print(int[] a)
    {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    }

    public int[] insert(int[] a)
    {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    }

    public int gcd(int a, int b)
    {
        if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        }
    }

    public void go()
    {
        int a = in.nextInt();
        int b = in.nextInt();

        int value = new Main().gcd(a, b);

        System.out.println(value);

    }

    public static void main(String[] args)
    {
        new Main().go();


    }
} public class Main
{

    public static Scanner in = new Scanner(System.in);

    public void print(int[] a)
    {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    }

    public int[] insert(int[] a)
    {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    }

    public int gcd(int a, int b)
    {
        if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        }
    }

    public void go()
    {
        int a = in.nextInt();
        int b = in.nextInt();

        int value = new Main().gcd(a, b);

        System.out.println(value);

    }

    public static void main(String[] args)
    {
        new Main().go();


    }
} Main

import java.util.*;

class Animal
{
    String name;
    String genus;
    int region;

    public Animal(String name, String genus, int region)
    {
        this.name = name;
        this.genus = genus;
        this.region = region;
    }

    public int getRegion()
    {
        return this.region;
    }

    public String getGenus()
    {
        return this.genus;
    }

    public String getName()
    {
        return this.name;
    }
}

class Human extends Animal
{
    String sex;
    String bloodGroup;

    public Human(String sex, String bloodGroup)
    {
        super("HS", "homo", 1);
        this.sex = sex;
        this.bloodGroup = bloodGroup;
    }

    public String getSex()
    {
        return sex;
    }

    public String getBloodGroup()
    {
        return bloodGroup;
    }
}

public class Main
{

    public static Scanner in = new Scanner(System.in);

    public void print(int[] a)
    {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    }

    public int[] insert(int[] a)
    {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    }

    public int gcd(int a, int b)
    {
        if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        }
    }

    public void go()
    {
        int a = in.nextInt();
        int b = in.nextInt();

        int value = new Main().gcd(a, b);

        System.out.println(value);

    }

    public static void main(String[] args)
    {
        new Main().go();


    }
}