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] );

      System.out.println( gcd(x,y) );
    }
  }

  static int gcd(int x, int y) {
    if( x<y ){
      int tmp = x; x = y; y = tmp;
    }

    int r;
    while( y>0 ) {
      r = x%y;
      x = y; y = r;
    }

    return x;
  }
} 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] );

      System.out.println( gcd(x,y) );
    }
  }

  static int gcd(int x, int y) {
    if( x<y ){
      int tmp = x; x = y; y = tmp;
    }

    int r;
    while( y>0 ) {
      r = x%y;
      x = y; y = r;
    }

    return x;
  }
} 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] );

      System.out.println( gcd(x,y) );
    }
  } 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] );

      System.out.println( gcd(x,y) );
    }
  } 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] );

      System.out.println( gcd(x,y) );
    } {

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

      System.out.println( gcd(x,y) );
    } 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 System.out.println( gcd(x,y) ) System.out.println System.out System System.out gcd(x,y) gcd x y String[] args args static int gcd(int x, int y) {
    if( x<y ){
      int tmp = x; x = y; y = tmp;
    }

    int r;
    while( y>0 ) {
      r = x%y;
      x = y; y = r;
    }

    return x;
  } gcd {
    if( x<y ){
      int tmp = x; x = y; y = tmp;
    }

    int r;
    while( y>0 ) {
      r = x%y;
      x = y; y = r;
    }

    return x;
  } if( x<y ){
      int tmp = x; x = y; y = tmp;
    } x<y x y {
      int tmp = x; x = y; y = tmp;
    } int tmp = x; tmp x x = y x y y = tmp y tmp int r; r while( y>0 ) {
      r = x%y;
      x = y; y = r;
    } y>0 y 0 {
      r = x%y;
      x = y; y = r;
    } r = x%y r x%y x y x = y x y y = r y r return x; x 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] );

      System.out.println( gcd(x,y) );
    }
  }

  static int gcd(int x, int y) {
    if( x<y ){
      int tmp = x; x = y; y = tmp;
    }

    int r;
    while( y>0 ) {
      r = x%y;
      x = y; y = r;
    }

    return x;
  }
} 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] );

      System.out.println( gcd(x,y) );
    }
  }

  static int gcd(int x, int y) {
    if( x<y ){
      int tmp = x; x = y; y = tmp;
    }

    int r;
    while( y>0 ) {
      r = x%y;
      x = y; y = r;
    }

    return x;
  }
} 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] );

      System.out.println( gcd(x,y) );
    }
  }

  static int gcd(int x, int y) {
    if( x<y ){
      int tmp = x; x = y; y = tmp;
    }

    int r;
    while( y>0 ) {
      r = x%y;
      x = y; y = r;
    }

    return x;
  }
}
