// ALDS1_1_B Greatest Common Divisor
import java.io.*;

class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         String[] input = br.readLine().split(" ");
         int x = Integer.parseInt(input[0]);
         int y = Integer.parseInt(input[1]);
         System.out.println(gcd(x, y));
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static int gcd(int x, int y) {
      int r;
      if (x <= y) swap(x, y);
      while (y > 0) {
         r = x % y;
         x = y;
         y = r;
      }
      return x;
   }
   static void swap(int x, int y) {
      int work;
      work = x;
      x = y;
      y = work;
   }
} import java.io.*; io.* java class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         String[] input = br.readLine().split(" ");
         int x = Integer.parseInt(input[0]);
         int y = Integer.parseInt(input[1]);
         System.out.println(gcd(x, y));
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static int gcd(int x, int y) {
      int r;
      if (x <= y) swap(x, y);
      while (y > 0) {
         r = x % y;
         x = y;
         y = r;
      }
      return x;
   }
   static void swap(int x, int y) {
      int work;
      work = x;
      x = y;
      y = work;
   }
} Main public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         String[] input = br.readLine().split(" ");
         int x = Integer.parseInt(input[0]);
         int y = Integer.parseInt(input[1]);
         System.out.println(gcd(x, y));
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   } main {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         String[] input = br.readLine().split(" ");
         int x = Integer.parseInt(input[0]);
         int y = Integer.parseInt(input[1]);
         System.out.println(gcd(x, y));
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
         String[] input = br.readLine().split(" ");
         int x = Integer.parseInt(input[0]);
         int y = Integer.parseInt(input[1]);
         System.out.println(gcd(x, y));
      }
      catch (Exception e) {
         e.printStackTrace();
      } catch (Exception e) {
         e.printStackTrace();
      } Exception e {
         e.printStackTrace();
      } e.printStackTrace() e.printStackTrace e {
         String[] input = br.readLine().split(" ");
         int x = Integer.parseInt(input[0]);
         int y = Integer.parseInt(input[1]);
         System.out.println(gcd(x, y));
      } String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(input[0]); x Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int y = Integer.parseInt(input[1]); y Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 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) {
      int r;
      if (x <= y) swap(x, y);
      while (y > 0) {
         r = x % y;
         x = y;
         y = r;
      }
      return x;
   } gcd {
      int r;
      if (x <= y) swap(x, y);
      while (y > 0) {
         r = x % y;
         x = y;
         y = r;
      }
      return x;
   } int r; r if (x <= y) swap(x, y); x <= y x y swap(x, y) swap x y 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 static void swap(int x, int y) {
      int work;
      work = x;
      x = y;
      y = work;
   } swap {
      int work;
      work = x;
      x = y;
      y = work;
   } int work; work work = x work x x = y x y y = work y work int x x int y y
// ALDS1_1_B Greatest Common Divisor
import java.io.*;

class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         String[] input = br.readLine().split(" ");
         int x = Integer.parseInt(input[0]);
         int y = Integer.parseInt(input[1]);
         System.out.println(gcd(x, y));
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static int gcd(int x, int y) {
      int r;
      if (x <= y) swap(x, y);
      while (y > 0) {
         r = x % y;
         x = y;
         y = r;
      }
      return x;
   }
   static void swap(int x, int y) {
      int work;
      work = x;
      x = y;
      y = work;
   }
}