import java.util.List;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		List<Integer> inputline = stdIn.getLine();
		int x = inputline.get(0);
		int y = inputline.get(1);
		int q,r;

		while(true) {
			q = x / y;
			r = x % y;
			if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			}
		}
	}
}
class Input{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public Input() {
	}

	public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	}

	public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} import java.util.List; List java.util import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		List<Integer> inputline = stdIn.getLine();
		int x = inputline.get(0);
		int y = inputline.get(1);
		int q,r;

		while(true) {
			q = x / y;
			r = x % y;
			if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			}
		}
	}
} Main public static void main(String[] args) {

		Input stdIn = new Input();
		List<Integer> inputline = stdIn.getLine();
		int x = inputline.get(0);
		int y = inputline.get(1);
		int q,r;

		while(true) {
			q = x / y;
			r = x % y;
			if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			}
		}
	} main {

		Input stdIn = new Input();
		List<Integer> inputline = stdIn.getLine();
		int x = inputline.get(0);
		int y = inputline.get(1);
		int q,r;

		while(true) {
			q = x / y;
			r = x % y;
			if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			}
		}
	} Input stdIn = new Input(); stdIn new Input() List<Integer> inputline = stdIn.getLine(); inputline stdIn.getLine() stdIn.getLine stdIn int x = inputline.get(0); x inputline.get(0) inputline.get inputline 0 int y = inputline.get(1); y inputline.get(1) inputline.get inputline 1 int q q r; r while(true) {
			q = x / y;
			r = x % y;
			if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			}
		} true {
			q = x / y;
			r = x % y;
			if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			}
		} q = x / y q x / y x y r = x % y r x % y x y if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			} r == 0 r 0 {
				System.out.println(y);
				break;
			} System.out.println(y) System.out.println System.out System System.out y break; {
				x = y;
				y = r;
			} x = y x y y = r y r String[] args args class Input{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public Input() {
	}

	public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	}

	public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) public Input() {
	} Input {
	} public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	} getValue {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	} int n = 0; n 0 try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			n = Integer.parseInt(br.readLine());
		} n = Integer.parseInt(br.readLine()) n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br return n; n public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	} getLine {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	} try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} String[] s = br.readLine().trim().split(" "); s br.readLine().trim().split(" ") br.readLine().trim().split br.readLine().trim() br.readLine().trim br.readLine() br.readLine br " " List<Integer> ary = new ArrayList<>(); ary new ArrayList<>() for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			} int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
				ary.add(Integer.parseInt(s[i]));
			} {
				ary.add(Integer.parseInt(s[i]));
			} ary.add(Integer.parseInt(s[i])) ary.add ary Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i return ary; ary return null; null public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	} close {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	} try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			br.close();
		} br.close() br.close br
import java.util.List;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		List<Integer> inputline = stdIn.getLine();
		int x = inputline.get(0);
		int y = inputline.get(1);
		int q,r;

		while(true) {
			q = x / y;
			r = x % y;
			if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			}
		}
	}
}
class Input{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public Input() {
	}

	public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	}

	public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}