import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    }
  }

  static int[] commonDivisor(int n) {
    int[] div = new int[5000];
    int[] buf = new int[5000];
    int counter = 0;

    for(int i=1, j=0, max=n; i<max; i++){
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    }
    int[] ret = new int[(counter)*2];
    for(int i=0 ; i != counter; i++){
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    }

    return ret;
  }

  static int calcRemaider(int x, int y) {
    int z = x>y ? x%y : y%x;

    if( x > y &&  z == 0 ) {
      System.out.println(y);
      System.exit(0);

    } else if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    }

    return z;
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    }
  }

  static int[] commonDivisor(int n) {
    int[] div = new int[5000];
    int[] buf = new int[5000];
    int counter = 0;

    for(int i=1, j=0, max=n; i<max; i++){
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    }
    int[] ret = new int[(counter)*2];
    for(int i=0 ; i != counter; i++){
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    }

    return ret;
  }

  static int calcRemaider(int x, int y) {
    int z = x>y ? x%y : y%x;

    if( x > y &&  z == 0 ) {
      System.out.println(y);
      System.exit(0);

    } else if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    }

    return z;
  }
} Main public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    }
  } main {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    }
  } try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    } {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt( str[0] ); x Integer.parseInt( str[0] ) Integer.parseInt Integer str[0] str 0 int y = Integer.parseInt( str[1] ); y Integer.parseInt( str[1] ) Integer.parseInt Integer str[1] str 1 int z = calcRemaider(x, y); z calcRemaider(x, y) calcRemaider x y int[] aDiv aDiv az; az int result=0; result 0 aDiv = commonDivisor( x>y ? y : x ) aDiv commonDivisor( x>y ? y : x ) commonDivisor x>y ? y : x x>y x y y x az = commonDivisor(z) az commonDivisor(z) commonDivisor z for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      } int i=0, j=0, max = az.length; int i=0 i 0 j=0 j 0 max = az.length; max az.length az az.length i<max i max i++ i++ i {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      } {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      } for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        } j=0; j=0 j 0 aDiv[j] <= az[i] aDiv[j] aDiv j az[i] az i j++ j++ j {
          if(aDiv[j] == az[i]) result = aDiv[j];
        } {
          if(aDiv[j] == az[i]) result = aDiv[j];
        } if(aDiv[j] == az[i]) result = aDiv[j]; aDiv[j] == az[i] aDiv[j] aDiv j az[i] az i result = aDiv[j] result aDiv[j] aDiv j System.out.println(result) System.out.println System.out System System.out result String[] args args static int[] commonDivisor(int n) {
    int[] div = new int[5000];
    int[] buf = new int[5000];
    int counter = 0;

    for(int i=1, j=0, max=n; i<max; i++){
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    }
    int[] ret = new int[(counter)*2];
    for(int i=0 ; i != counter; i++){
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    }

    return ret;
  } commonDivisor {
    int[] div = new int[5000];
    int[] buf = new int[5000];
    int counter = 0;

    for(int i=1, j=0, max=n; i<max; i++){
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    }
    int[] ret = new int[(counter)*2];
    for(int i=0 ; i != counter; i++){
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    }

    return ret;
  } int[] div = new int[5000]; div new int[5000] 5000 int[] buf = new int[5000]; buf new int[5000] 5000 int counter = 0; counter 0 for(int i=1, j=0, max=n; i<max; i++){
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    } int i=1, j=0, max=n; int i=1 i 1 j=0 j 0 max=n; max n i<max i max i++ i++ i {
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    } {
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    } if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      } n%i == 0 n%i n i 0 {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      } div[j++] = i div[j++] div j++ j i max = n/i max n/i n i buf[++counter] = max buf[++counter] buf ++counter counter max int[] ret = new int[(counter)*2]; ret new int[(counter)*2] (counter)*2 (counter) 2 for(int i=0 ; i != counter; i++){
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    } int i=0 ; int i=0 ; i 0 i != counter i counter i++ i++ i {
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    } {
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    } ret[i] = div[i] ret[i] ret i div[i] div i ret[counter + i] = buf[counter-i] ret[counter + i] ret counter + i counter i buf[counter-i] buf counter-i counter i return ret; ret int n n static int calcRemaider(int x, int y) {
    int z = x>y ? x%y : y%x;

    if( x > y &&  z == 0 ) {
      System.out.println(y);
      System.exit(0);

    } else if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    }

    return z;
  } calcRemaider {
    int z = x>y ? x%y : y%x;

    if( x > y &&  z == 0 ) {
      System.out.println(y);
      System.exit(0);

    } else if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    }

    return z;
  } int z = x>y ? x%y : y%x; z x>y ? x%y : y%x x>y x y x%y x y y%x y x if( x > y &&  z == 0 ) {
      System.out.println(y);
      System.exit(0);

    } else if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    } x > y &&  z == 0 x > y x y z == 0 z 0 {
      System.out.println(y);
      System.exit(0);

    } System.out.println(y) System.out.println System.out System System.out y System.exit(0) System.exit System 0 if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    } z == 0 z 0 {
      System.out.println(x);
      System.exit(0);
    } System.out.println(x) System.out.println System.out System System.out x System.exit(0) System.exit System 0 return z; z int x x int y y public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    }
  }

  static int[] commonDivisor(int n) {
    int[] div = new int[5000];
    int[] buf = new int[5000];
    int counter = 0;

    for(int i=1, j=0, max=n; i<max; i++){
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    }
    int[] ret = new int[(counter)*2];
    for(int i=0 ; i != counter; i++){
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    }

    return ret;
  }

  static int calcRemaider(int x, int y) {
    int z = x>y ? x%y : y%x;

    if( x > y &&  z == 0 ) {
      System.out.println(y);
      System.exit(0);

    } else if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    }

    return z;
  }
} public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    }
  }

  static int[] commonDivisor(int n) {
    int[] div = new int[5000];
    int[] buf = new int[5000];
    int counter = 0;

    for(int i=1, j=0, max=n; i<max; i++){
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    }
    int[] ret = new int[(counter)*2];
    for(int i=0 ; i != counter; i++){
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    }

    return ret;
  }

  static int calcRemaider(int x, int y) {
    int z = x>y ? x%y : y%x;

    if( x > y &&  z == 0 ) {
      System.out.println(y);
      System.exit(0);

    } else if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    }

    return z;
  }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );
      int z = calcRemaider(x, y);

      int[] aDiv,az;
      int result=0;

      aDiv = commonDivisor( x>y ? y : x );
      az = commonDivisor(z);
      for( int i=0, j=0, max = az.length; i<max; i++ ) {
        for( j=0; aDiv[j] <= az[i]; j++){
          if(aDiv[j] == az[i]) result = aDiv[j];
        }
      }

      System.out.println(result);
    }
  }

  static int[] commonDivisor(int n) {
    int[] div = new int[5000];
    int[] buf = new int[5000];
    int counter = 0;

    for(int i=1, j=0, max=n; i<max; i++){
      if( n%i == 0) {
        div[j++] = i;
        max = n/i;
        buf[++counter] = max;
      }
    }
    int[] ret = new int[(counter)*2];
    for(int i=0 ; i != counter; i++){
      ret[i] = div[i];
      ret[counter + i] = buf[counter-i];
    }

    return ret;
  }

  static int calcRemaider(int x, int y) {
    int z = x>y ? x%y : y%x;

    if( x > y &&  z == 0 ) {
      System.out.println(y);
      System.exit(0);

    } else if( z == 0 ) {
      System.out.println(x);
      System.exit(0);
    }

    return z;
  }
}
