import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = Math.max(a, b);
    int y = Math.min(a, b);
    boolean equal = true;
    if(x == y) {
      System.out.println(x);
      equal = false;
    }
    x %= y;
    int max = 0;
    for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    }
    if(equal) {
      System.out.println(max);
    }
  }
}
 import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = Math.max(a, b);
    int y = Math.min(a, b);
    boolean equal = true;
    if(x == y) {
      System.out.println(x);
      equal = false;
    }
    x %= y;
    int max = 0;
    for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    }
    if(equal) {
      System.out.println(max);
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = Math.max(a, b);
    int y = Math.min(a, b);
    boolean equal = true;
    if(x == y) {
      System.out.println(x);
      equal = false;
    }
    x %= y;
    int max = 0;
    for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    }
    if(equal) {
      System.out.println(max);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = Math.max(a, b);
    int y = Math.min(a, b);
    boolean equal = true;
    if(x == y) {
      System.out.println(x);
      equal = false;
    }
    x %= y;
    int max = 0;
    for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    }
    if(equal) {
      System.out.println(max);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int x = Math.max(a, b); x Math.max(a, b) Math.max Math a b int y = Math.min(a, b); y Math.min(a, b) Math.min Math a b boolean equal = true; equal true if(x == y) {
      System.out.println(x);
      equal = false;
    } x == y x y {
      System.out.println(x);
      equal = false;
    } System.out.println(x) System.out.println System.out System System.out x equal = false equal false x %= y x y int max = 0; max 0 for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    } int i = Math.min(x, y); int i = Math.min(x, y); i Math.min(x, y) Math.min Math x y i > 0 i 0 i-- i-- i {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    } {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    } if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      } x % i == 0 && y % i == 0 x % i == 0 x % i x i 0 y % i == 0 y % i y i 0 {
        max = i;
        break;
      } max = i max i break; if(equal) {
      System.out.println(max);
    } equal {
      System.out.println(max);
    } System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = Math.max(a, b);
    int y = Math.min(a, b);
    boolean equal = true;
    if(x == y) {
      System.out.println(x);
      equal = false;
    }
    x %= y;
    int max = 0;
    for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    }
    if(equal) {
      System.out.println(max);
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = Math.max(a, b);
    int y = Math.min(a, b);
    boolean equal = true;
    if(x == y) {
      System.out.println(x);
      equal = false;
    }
    x %= y;
    int max = 0;
    for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    }
    if(equal) {
      System.out.println(max);
    }
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = Math.max(a, b);
    int y = Math.min(a, b);
    boolean equal = true;
    if(x == y) {
      System.out.println(x);
      equal = false;
    }
    x %= y;
    int max = 0;
    for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    }
    if(equal) {
      System.out.println(max);
    }
  }
}

