import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int tmp, remainder;
		int[] next = {0, 0};
		Scanner in = new Scanner(System.in);
		next[0] = Integer.parseInt(in.next());
		next[1] = Integer.parseInt(in.next());
		
		if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		}
		int i = 1;
		while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		}
	}	
			
	public static int gcd(int big, int small){
		int remainder = big % small;
		return remainder;	
	}
	
}
		 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		int tmp, remainder;
		int[] next = {0, 0};
		Scanner in = new Scanner(System.in);
		next[0] = Integer.parseInt(in.next());
		next[1] = Integer.parseInt(in.next());
		
		if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		}
		int i = 1;
		while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		}
	}	
			
	public static int gcd(int big, int small){
		int remainder = big % small;
		return remainder;	
	}
	
} Main public static void main(String[] args){
		int tmp, remainder;
		int[] next = {0, 0};
		Scanner in = new Scanner(System.in);
		next[0] = Integer.parseInt(in.next());
		next[1] = Integer.parseInt(in.next());
		
		if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		}
		int i = 1;
		while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		}
	} main {
		int tmp, remainder;
		int[] next = {0, 0};
		Scanner in = new Scanner(System.in);
		next[0] = Integer.parseInt(in.next());
		next[1] = Integer.parseInt(in.next());
		
		if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		}
		int i = 1;
		while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		}
	} int tmp tmp remainder; remainder int[] next = {0, 0}; next {0, 0} 0 0 Scanner in = new Scanner(System.in); in new Scanner(System.in) next[0] = Integer.parseInt(in.next()) next[0] next 0 Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in next[1] = Integer.parseInt(in.next()) next[1] next 1 Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		} next[0] < next[1] next[0] next 0 next[1] next 1 {
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		} tmp = next[1] tmp next[1] next 1 next[1] = next[0] next[1] next 1 next[0] next 0 next[0] = tmp next[0] next 0 tmp int i = 1; i 1 while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		} i == 1 i 1 {
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		} remainder = gcd(next[0], next[1]) remainder gcd(next[0], next[1]) gcd next[0] next 0 next[1] next 1 if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			} remainder == 0 remainder 0 {
				System.out.println(next[1]);
				System.exit(0);
			} System.out.println(next[1]) System.out.println System.out System System.out next[1] next 1 System.exit(0) System.exit System 0 next[0] = remainder next[0] next 0 remainder remainder = gcd(next[1], next[0]) remainder gcd(next[1], next[0]) gcd next[1] next 1 next[0] next 0 if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			} remainder == 0 remainder 0 {
				System.out.println(next[0]);
				System.exit(0);
			} System.out.println(next[0]) System.out.println System.out System System.out next[0] next 0 System.exit(0) System.exit System 0 next[1] = remainder next[1] next 1 remainder String[] args args public static int gcd(int big, int small){
		int remainder = big % small;
		return remainder;	
	} gcd {
		int remainder = big % small;
		return remainder;	
	} int remainder = big % small; remainder big % small big small return remainder; remainder int big big int small small public class Main {
	public static void main(String[] args){
		int tmp, remainder;
		int[] next = {0, 0};
		Scanner in = new Scanner(System.in);
		next[0] = Integer.parseInt(in.next());
		next[1] = Integer.parseInt(in.next());
		
		if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		}
		int i = 1;
		while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		}
	}	
			
	public static int gcd(int big, int small){
		int remainder = big % small;
		return remainder;	
	}
	
} public class Main {
	public static void main(String[] args){
		int tmp, remainder;
		int[] next = {0, 0};
		Scanner in = new Scanner(System.in);
		next[0] = Integer.parseInt(in.next());
		next[1] = Integer.parseInt(in.next());
		
		if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		}
		int i = 1;
		while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		}
	}	
			
	public static int gcd(int big, int small){
		int remainder = big % small;
		return remainder;	
	}
	
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int tmp, remainder;
		int[] next = {0, 0};
		Scanner in = new Scanner(System.in);
		next[0] = Integer.parseInt(in.next());
		next[1] = Integer.parseInt(in.next());
		
		if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		}
		int i = 1;
		while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		}
	}	
			
	public static int gcd(int big, int small){
		int remainder = big % small;
		return remainder;	
	}
	
}
		