import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] nums = br.readLine().split(" ");
            int x = Integer.parseInt(nums[0]);
            int y = Integer.parseInt(nums[1]);

            while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            }
            System.out.println(x);
        } catch (IOException e) {
            System.out.println(e);
        }
    }
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] nums = br.readLine().split(" ");
            int x = Integer.parseInt(nums[0]);
            int y = Integer.parseInt(nums[1]);

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

            while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            }
            System.out.println(x);
        } catch (IOException e) {
            System.out.println(e);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] nums = br.readLine().split(" ");
            int x = Integer.parseInt(nums[0]);
            int y = Integer.parseInt(nums[1]);

            while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            }
            System.out.println(x);
        } catch (IOException e) {
            System.out.println(e);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
            String[] nums = br.readLine().split(" ");
            int x = Integer.parseInt(nums[0]);
            int y = Integer.parseInt(nums[1]);

            while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            }
            System.out.println(x);
        } catch (IOException e) {
            System.out.println(e);
        } catch (IOException e) {
            System.out.println(e);
        } IOException e {
            System.out.println(e);
        } System.out.println(e) System.out.println System.out System System.out e {
            String[] nums = br.readLine().split(" ");
            int x = Integer.parseInt(nums[0]);
            int y = Integer.parseInt(nums[1]);

            while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            }
            System.out.println(x);
        } String[] nums = br.readLine().split(" "); nums br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(nums[0]); x Integer.parseInt(nums[0]) Integer.parseInt Integer nums[0] nums 0 int y = Integer.parseInt(nums[1]); y Integer.parseInt(nums[1]) Integer.parseInt Integer nums[1] nums 1 while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            } y != 0 y 0 {
                int tmp = y;
                y = x % y;
                x =tmp;
            } int tmp = y; tmp y y = x % y y x % y x y x =tmp x tmp System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] nums = br.readLine().split(" ");
            int x = Integer.parseInt(nums[0]);
            int y = Integer.parseInt(nums[1]);

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

            while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            }
            System.out.println(x);
        } catch (IOException e) {
            System.out.println(e);
        }
    }
} Main
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] nums = br.readLine().split(" ");
            int x = Integer.parseInt(nums[0]);
            int y = Integer.parseInt(nums[1]);

            while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            }
            System.out.println(x);
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}