#include <stdio.h>

int in(){
  int n = 0;
  int c = getchar_unlocked();
  do n = 10*n + (c & 0xf), c = getchar_unlocked();
  while (c >= '0');
  return n;
}

int haf(int a, int b){
  int r;
  while (b != 0) r = a%b, a = b, b = r;
  return a;
}

int main(){
  int a, b;

  a = in(), b = in();
  printf("%d\n", haf(a, b));
  return 0;
}

