import java.util.Scanner;
import java.io.File;
import java.io.PrintWriter;

/**
 * Created by IntelliJ IDEA.
 * User: m09fpv
 * Date: 07.10.2009
 * Time: 18:35:37
 * To change this template use File | Settings | File Templates.
 */
public class gcd {
    public static void main(String[]  args) throws Exception {
Scanner in=new  Scanner(new File("gcd.in"));
PrintWriter out=new PrintWriter(new File("gcd.out"));
  int n=in.nextInt();
  int m=in.nextInt();
   int k=0;
   int nod=0;
 for( int i=1;i<=n+m;i++){
   if(n%i==0&&m%i==0){
      k=i;

     if (k>nod){
       nod=k;
               }
                     }
                        }
       out.print(nod);
          out.close();
          in.close();
   }
 }