import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();

    if (x < y) {
      int t = x;
      x = y;
      y = t;
    }
    x = x % y;

    while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    }

    System.out.println(y);
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();

    if (x < y) {
      int t = x;
      x = y;
      y = t;
    }
    x = x % y;

    while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    }

    System.out.println(y);
  }
} Main public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();

    if (x < y) {
      int t = x;
      x = y;
      y = t;
    }
    x = x % y;

    while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    }

    System.out.println(y);
  } main {
    Scanner stdIn = new Scanner(System.in);
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();

    if (x < y) {
      int t = x;
      x = y;
      y = t;
    }
    x = x % y;

    while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    }

    System.out.println(y);
  } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int x = stdIn.nextInt(); x stdIn.nextInt() stdIn.nextInt stdIn int y = stdIn.nextInt(); y stdIn.nextInt() stdIn.nextInt stdIn if (x < y) {
      int t = x;
      x = y;
      y = t;
    } x < y x y {
      int t = x;
      x = y;
      y = t;
    } int t = x; t x x = y x y y = t y t x = x % y x x % y x y while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    } x != 0 x 0 {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    } int t = x; t x x = y x y y = t y t x = x % y x x % y x y System.out.println(y) System.out.println System.out System System.out y String[] args args public class Main {

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();

    if (x < y) {
      int t = x;
      x = y;
      y = t;
    }
    x = x % y;

    while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    }

    System.out.println(y);
  }
} public class Main {

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();

    if (x < y) {
      int t = x;
      x = y;
      y = t;
    }
    x = x % y;

    while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    }

    System.out.println(y);
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();

    if (x < y) {
      int t = x;
      x = y;
      y = t;
    }
    x = x % y;

    while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    }

    System.out.println(y);
  }
}