import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static int euclidean(final int x, final int y) {
		int a = x<y ? y : x;
		int b = x<y ? x : y;
		int r = a % b;
		
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		
		return b;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) {
		try {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static int euclidean(final int x, final int y) {
		int a = x<y ? y : x;
		int b = x<y ? x : y;
		int r = a % b;
		
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		
		return b;
	}
} Main public static void main(String[] args) {
		try {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	} main {
		try {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	} try {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} catch (Exception e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} Exception e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} final BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) final String[] line = in.readLine().split(" "); line in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " in.close() in.close in final int x = Integer.parseInt(line[0]); x Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 final int y = Integer.parseInt(line[1]); y Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 System.out.println(String.valueOf(euclidean(x, y))) System.out.println System.out System System.out String.valueOf(euclidean(x, y)) String.valueOf String euclidean(x, y) euclidean x y String[] args args public static int euclidean(final int x, final int y) {
		int a = x<y ? y : x;
		int b = x<y ? x : y;
		int r = a % b;
		
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		
		return b;
	} euclidean {
		int a = x<y ? y : x;
		int b = x<y ? x : y;
		int r = a % b;
		
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		
		return b;
	} int a = x<y ? y : x; a x<y ? y : x x<y x y y x int b = x<y ? x : y; b x<y ? x : y x<y x y x y int r = a % b; r a % b a b while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		} r != 0 r 0 {
			a = b;
			b = r;
			r = a % b;
		} a = b a b b = r b r r = a % b r a % b a b return b; b final int x x final int y y public class Main {
	public static void main(String[] args) {
		try {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static int euclidean(final int x, final int y) {
		int a = x<y ? y : x;
		int b = x<y ? x : y;
		int r = a % b;
		
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		
		return b;
	}
} public class Main {
	public static void main(String[] args) {
		try {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static int euclidean(final int x, final int y) {
		int a = x<y ? y : x;
		int b = x<y ? x : y;
		int r = a % b;
		
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		
		return b;
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			final String[] line = in.readLine().split(" ");
			in.close();
			
			final int x = Integer.parseInt(line[0]);
			final int y = Integer.parseInt(line[1]);
			
			System.out.println(String.valueOf(euclidean(x, y)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static int euclidean(final int x, final int y) {
		int a = x<y ? y : x;
		int b = x<y ? x : y;
		int r = a % b;
		
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		
		return b;
	}
}