import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] str = br.readLine().split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        int tmp;
        if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        }
        while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        }
        out.println(y);
        out.flush();
    }

    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] str = br.readLine().split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        int tmp;
        if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        }
        while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        }
        out.println(y);
        out.flush();
    }

    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
} Main public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] str = br.readLine().split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        int tmp;
        if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        }
        while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        }
        out.println(y);
        out.flush();
    } exec {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] str = br.readLine().split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        int tmp;
        if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        }
        while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        }
        out.println(y);
        out.flush();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(str[0]); x Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int y = Integer.parseInt(str[1]); y Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int tmp; tmp if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        } x<y x y {
        	tmp=x;
        	x=y;
        	y=tmp;
        } tmp=x tmp x x=y x y y=tmp y tmp while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        } x%y>0 x%y x y 0 {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        } tmp=y tmp y y=x%y y x%y x y x=tmp x tmp out.println(y) out.println out y out.flush() out.flush out public static void main(String[] args) throws IOException {
        new Main().exec();
    } main {
        new Main().exec();
    } new Main().exec() new Main().exec new Main() String[] args args public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] str = br.readLine().split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        int tmp;
        if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        }
        while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        }
        out.println(y);
        out.flush();
    }

    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
} public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] str = br.readLine().split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        int tmp;
        if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        }
        while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        }
        out.println(y);
        out.flush();
    }

    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] str = br.readLine().split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        int tmp;
        if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        }
        while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        }
        out.println(y);
        out.flush();
    }

    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}