import java.io.*;
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Integer x = Integer.parseInt(s.next());
		Integer y = Integer.parseInt(s.next());
		s.close();
		if(x > y){
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		}
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Integer x = Integer.parseInt(s.next());
		Integer y = Integer.parseInt(s.next());
		s.close();
		if(x > y){
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		}
	}
} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Integer x = Integer.parseInt(s.next());
		Integer y = Integer.parseInt(s.next());
		s.close();
		if(x > y){
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		}
	} main {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Integer x = Integer.parseInt(s.next());
		Integer y = Integer.parseInt(s.next());
		s.close();
		if(x > y){
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		}
	} Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); s new Scanner(new BufferedReader(new InputStreamReader(System.in))) Integer x = Integer.parseInt(s.next()); x Integer.parseInt(s.next()) Integer.parseInt Integer s.next() s.next s Integer y = Integer.parseInt(s.next()); y Integer.parseInt(s.next()) Integer.parseInt Integer s.next() s.next s s.close() s.close s if(x > y){
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		} x > y x y {
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		} Integer remain = x % y; remain x % y x y Integer new_remain = y % remain; new_remain y % remain y remain Integer bkp = 0; bkp 0 while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			} new_remain > 0 new_remain 0 {
				bkp = new_remain;
				new_remain = remain % new_remain;
			} bkp = new_remain bkp new_remain new_remain = remain % new_remain new_remain remain % new_remain remain new_remain System.out.println(bkp) System.out.println System.out System System.out bkp if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		} y > x y x {
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		} Integer remain = y % x; remain y % x y x Integer new_remain = x % remain; new_remain x % remain x remain Integer bkp = 0; bkp 0 while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			} new_remain > 0 new_remain 0 {
				bkp = new_remain;
				new_remain = remain % new_remain;
			} bkp = new_remain bkp new_remain new_remain = remain % new_remain new_remain remain % new_remain remain new_remain System.out.println(bkp) System.out.println System.out System System.out bkp {
			System.out.println(y);
		} System.out.println(y) System.out.println System.out System System.out y String[] args args public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Integer x = Integer.parseInt(s.next());
		Integer y = Integer.parseInt(s.next());
		s.close();
		if(x > y){
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		}
	}
} public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Integer x = Integer.parseInt(s.next());
		Integer y = Integer.parseInt(s.next());
		s.close();
		if(x > y){
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		}
	}
} Main
import java.io.*;
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Integer x = Integer.parseInt(s.next());
		Integer y = Integer.parseInt(s.next());
		s.close();
		if(x > y){
			Integer remain = x % y;
			Integer new_remain = y % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else if(y > x){
			Integer remain = y % x;
			Integer new_remain = x % remain;
			Integer bkp = 0;
			while(new_remain > 0){
				bkp = new_remain;
				new_remain = remain % new_remain;
			}
			System.out.println(bkp);
		}
		else{
			System.out.println(y);
		}
	}
}