
class Euclides 
{
  /* Recebe m e n do Inputstream e devolve o mdc(m,n) */

  public static void main( String[] args) 
  {
    
    int m = Integer.parseInt(args[0]);
    int n = Integer.parseInt(args[1]);
    
    int x = m;
    int y = n;
    
    int r = x % y;
    int d;
    
    
    while( r != 0 ){
      x = y;
      y = r;
      r = x % y;
    }
    d = y;
    
    System.out.println(d);
  }
}
