import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int x=Integer.parseInt(scan.next());
    int y=Integer.parseInt(scan.next());
    if(x<y){
      int tmp=x;
      x=y;
      y=tmp;
    }
    while(y>0){
      int r=x%y;
      x=y;
      y=r;
    }

    System.out.println(x);
  }
}
 import java.io.*; io.* java import java.util.*; util.* java import java.lang.*; lang.* java class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int x=Integer.parseInt(scan.next());
    int y=Integer.parseInt(scan.next());
    if(x<y){
      int tmp=x;
      x=y;
      y=tmp;
    }
    while(y>0){
      int r=x%y;
      x=y;
      y=r;
    }

    System.out.println(x);
  }
} Main public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int x=Integer.parseInt(scan.next());
    int y=Integer.parseInt(scan.next());
    if(x<y){
      int tmp=x;
      x=y;
      y=tmp;
    }
    while(y>0){
      int r=x%y;
      x=y;
      y=r;
    }

    System.out.println(x);
  } main {
    Scanner scan=new Scanner(System.in);
    int x=Integer.parseInt(scan.next());
    int y=Integer.parseInt(scan.next());
    if(x<y){
      int tmp=x;
      x=y;
      y=tmp;
    }
    while(y>0){
      int r=x%y;
      x=y;
      y=r;
    }

    System.out.println(x);
  } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int x=Integer.parseInt(scan.next()); x Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int y=Integer.parseInt(scan.next()); y Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan 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 while(y>0){
      int r=x%y;
      x=y;
      y=r;
    } y>0 y 0 {
      int r=x%y;
      x=y;
      y=r;
    } int r=x%y; r x%y x y x=y x y y=r y r System.out.println(x) System.out.println System.out System System.out x String[] args args
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int x=Integer.parseInt(scan.next());
    int y=Integer.parseInt(scan.next());
    if(x<y){
      int tmp=x;
      x=y;
      y=tmp;
    }
    while(y>0){
      int r=x%y;
      x=y;
      y=r;
    }

    System.out.println(x);
  }
}

