/**
 * Created by IntelliJ IDEA.
 * User: m09aaa
 * Date: 07.09.2009
 * Time: 14:11:09
 * To change this template use File | Settings | File Templates.
 */      import java.util.*;
 import java.io.*;

   public class nusya {
        public static void main ( String[] args ) throws Exception {
       Scanner in=new Scanner (new File("gcd.in"));
            int x=in.nextInt();
            int y=in.nextInt();

            while (x!=y)
            {
                if (x>y) { while (x>y) {x=x-y;}}
               else {while (y>x) {y=y-x;}}
            }
                        PrintWriter out=new PrintWriter (new File("gcd.out"));
                       out.println(x);
                       out.close ();
   }
   }

