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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			x = in.readLine();
			String[] ab = x.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			x = in.readLine();
			String[] ab = x.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			x = in.readLine();
			String[] ab = x.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			x = in.readLine();
			String[] ab = x.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String x = ""; x "" try {
			x = in.readLine();
			String[] ab = x.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} NumberFormatException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} IOException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			x = in.readLine();
			String[] ab = x.split(" ");

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

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			x = in.readLine();
			String[] ab = x.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			x = in.readLine();
			String[] ab = x.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}