import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      int a,b,c,r;
      Scanner  sc =new Scanner(System.in);
      a=sc.nextInt();
      b=sc.nextInt();
      if (a<b) {
          c=a;
          a=b;
          b=c;
      }  
      r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
System.out.println(b);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
      int a,b,c,r;
      Scanner  sc =new Scanner(System.in);
      a=sc.nextInt();
      b=sc.nextInt();
      if (a<b) {
          c=a;
          a=b;
          b=c;
      }  
      r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
System.out.println(b);
    }
} Main public static void main(String[] args) {
      int a,b,c,r;
      Scanner  sc =new Scanner(System.in);
      a=sc.nextInt();
      b=sc.nextInt();
      if (a<b) {
          c=a;
          a=b;
          b=c;
      }  
      r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
System.out.println(b);
    } main {
      int a,b,c,r;
      Scanner  sc =new Scanner(System.in);
      a=sc.nextInt();
      b=sc.nextInt();
      if (a<b) {
          c=a;
          a=b;
          b=c;
      }  
      r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
System.out.println(b);
    } int a a b b c c r; r Scanner  sc =new Scanner(System.in); sc new Scanner(System.in) a=sc.nextInt() a sc.nextInt() sc.nextInt sc b=sc.nextInt() b sc.nextInt() sc.nextInt sc if (a<b) {
          c=a;
          a=b;
          b=c;
      } a<b a b {
          c=a;
          a=b;
          b=c;
      } c=a c a a=b a b b=c b c r=a%b r a%b a b while(r!=0){
a=b;
b=r;
r=a%b;
} r!=0 r 0 {
a=b;
b=r;
r=a%b;
} a=b a b b=r b r r=a%b r a%b a b System.out.println(b) System.out.println System.out System System.out b String[] args args public class Main {
    public static void main(String[] args) {
      int a,b,c,r;
      Scanner  sc =new Scanner(System.in);
      a=sc.nextInt();
      b=sc.nextInt();
      if (a<b) {
          c=a;
          a=b;
          b=c;
      }  
      r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
System.out.println(b);
    }
} public class Main {
    public static void main(String[] args) {
      int a,b,c,r;
      Scanner  sc =new Scanner(System.in);
      a=sc.nextInt();
      b=sc.nextInt();
      if (a<b) {
          c=a;
          a=b;
          b=c;
      }  
      r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
System.out.println(b);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      int a,b,c,r;
      Scanner  sc =new Scanner(System.in);
      a=sc.nextInt();
      b=sc.nextInt();
      if (a<b) {
          c=a;
          a=b;
          b=c;
      }  
      r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
System.out.println(b);
    }
}
