import java.util.*;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int a = Integer.parseInt(input[0]);
      int b = Integer.parseInt(input[1]);
      
      System.out.println(gcd(a,b));
   }
   
   
   public static int gcd(int a, int b) {
      if (a % b == 0) {
         return b;
      } else {
         return gcd(b, a % b);
      }
   }
} import java.util.*; util.* java public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int a = Integer.parseInt(input[0]);
      int b = Integer.parseInt(input[1]);
      
      System.out.println(gcd(a,b));
   }
   
   
   public static int gcd(int a, int b) {
      if (a % b == 0) {
         return b;
      } else {
         return gcd(b, a % b);
      }
   }
} Main public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int a = Integer.parseInt(input[0]);
      int b = Integer.parseInt(input[1]);
      
      System.out.println(gcd(a,b));
   } main {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int a = Integer.parseInt(input[0]);
      int b = Integer.parseInt(input[1]);
      
      System.out.println(gcd(a,b));
   } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] input = sc.nextLine().split(" "); input sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int a = Integer.parseInt(input[0]); a Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int b = Integer.parseInt(input[1]); b Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 System.out.println(gcd(a,b)) System.out.println System.out System System.out gcd(a,b) gcd a b String[] args args public static int gcd(int a, int b) {
      if (a % b == 0) {
         return b;
      } else {
         return gcd(b, a % b);
      }
   } gcd {
      if (a % b == 0) {
         return b;
      } else {
         return gcd(b, a % b);
      }
   } if (a % b == 0) {
         return b;
      } else {
         return gcd(b, a % b);
      } a % b == 0 a % b a b 0 {
         return b;
      } return b; b {
         return gcd(b, a % b);
      } return gcd(b, a % b); gcd(b, a % b) gcd b a % b a b int a a int b b public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int a = Integer.parseInt(input[0]);
      int b = Integer.parseInt(input[1]);
      
      System.out.println(gcd(a,b));
   }
   
   
   public static int gcd(int a, int b) {
      if (a % b == 0) {
         return b;
      } else {
         return gcd(b, a % b);
      }
   }
} public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int a = Integer.parseInt(input[0]);
      int b = Integer.parseInt(input[1]);
      
      System.out.println(gcd(a,b));
   }
   
   
   public static int gcd(int a, int b) {
      if (a % b == 0) {
         return b;
      } else {
         return gcd(b, a % b);
      }
   }
} Main
import java.util.*;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int a = Integer.parseInt(input[0]);
      int b = Integer.parseInt(input[1]);
      
      System.out.println(gcd(a,b));
   }
   
   
   public static int gcd(int a, int b) {
      if (a % b == 0) {
         return b;
      } else {
         return gcd(b, a % b);
      }
   }
}
