import java.io.*;

public class Main {
  public static void main(String[] args) {
    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } catch( IOException e ) {
    }
  }
} import java.io.*; io.* java public class Main {
  public static void main(String[] args) {
    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } catch( IOException e ) {
    }
  }
} Main public static void main(String[] args) {
    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } catch( IOException e ) {
    }
  } main {
    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } catch( IOException e ) {
    }
  } try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } catch( IOException e ) {
    } catch( IOException e ) {
    } IOException e {
    } {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String input = new String(in.readLine()); input new String(in.readLine()) String[] inputArr = input.split(" "); inputArr input.split(" ") input.split input " " int x = Integer.parseInt(inputArr[0]); x Integer.parseInt(inputArr[0]) Integer.parseInt Integer inputArr[0] inputArr 0 int y = Integer.parseInt(inputArr[1]); y Integer.parseInt(inputArr[1]) Integer.parseInt Integer inputArr[1] inputArr 1 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 ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       } x > 0 x 0 {
         int tmp = x;
         x = y % x;
         y = tmp;
       } int tmp = x; tmp x x = y % x x y % x y x y = tmp y tmp System.out.println(y) System.out.println System.out System System.out y String[] args args public class Main {
  public static void main(String[] args) {
    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } catch( IOException e ) {
    }
  }
} public class Main {
  public static void main(String[] args) {
    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } catch( IOException e ) {
    }
  }
} Main
import java.io.*;

public class Main {
  public static void main(String[] args) {
    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = new String(in.readLine());
      String[] inputArr = input.split(" ");
      int x = Integer.parseInt(inputArr[0]);
      int y = Integer.parseInt(inputArr[1]);
      if ( x > y ) {
        int tmp = x;
        x = y;
        y = tmp;
       }
       while ( x > 0 ) {
         int tmp = x;
         x = y % x;
         y = tmp;
       }
       System.out.println(y);
    } catch( IOException e ) {
    }
  }
}