import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String[] str = new String[2];
		int count = 0; 
		while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		}
		
		String[] split = str[0].split(" ");
		int facter[];
		facter = new int[split.length];

		for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		}
		//swap
		if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		}
		
		int r = 0; 
		int x = facter[0];
		int y = facter[1];
		
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		System.out.println(x);
		
		
		
	}

} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String[] str = new String[2];
		int count = 0; 
		while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		}
		
		String[] split = str[0].split(" ");
		int facter[];
		facter = new int[split.length];

		for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		}
		//swap
		if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		}
		
		int r = 0; 
		int x = facter[0];
		int y = facter[1];
		
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		System.out.println(x);
		
		
		
	}

} Main public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String[] str = new String[2];
		int count = 0; 
		while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		}
		
		String[] split = str[0].split(" ");
		int facter[];
		facter = new int[split.length];

		for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		}
		//swap
		if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		}
		
		int r = 0; 
		int x = facter[0];
		int y = facter[1];
		
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		System.out.println(x);
		
		
		
	} main {
		
		Scanner in = new Scanner(System.in);
		String[] str = new String[2];
		int count = 0; 
		while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		}
		
		String[] split = str[0].split(" ");
		int facter[];
		facter = new int[split.length];

		for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		}
		//swap
		if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		}
		
		int r = 0; 
		int x = facter[0];
		int y = facter[1];
		
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		System.out.println(x);
		
		
		
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String[] str = new String[2]; str new String[2] 2 int count = 0; count 0 while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		} in.hasNext() in.hasNext in {
			String buf = in.nextLine();
			str[count] = buf;
		} String buf = in.nextLine(); buf in.nextLine() in.nextLine in str[count] = buf str[count] str count buf String[] split = str[0].split(" "); split str[0].split(" ") str[0].split str[0] str 0 " " int facter[]; facter facter = new int[split.length] facter new int[split.length] split.length split split.length for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		} int i = 0; int i = 0; i 0 i < split.length i split.length split split.length i++ i++ i {
			facter[i] = Integer.parseInt(split[i]);
			
		} {
			facter[i] = Integer.parseInt(split[i]);
			
		} facter[i] = Integer.parseInt(split[i]) facter[i] facter i Integer.parseInt(split[i]) Integer.parseInt Integer split[i] split i if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		} facter[0] < facter[1] facter[0] facter 0 facter[1] facter 1 {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		} int temp = facter[0]; temp facter[0] facter 0 facter[0] = facter[1] facter[0] facter 0 facter[1] facter 1 facter[1] = temp facter[1] facter 1 temp int r = 0; r 0 int x = facter[0]; x facter[0] facter 0 int y = facter[1]; y facter[1] facter 1 while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		} y > 0 y 0 {
			r = x % y;
			x = y;
			y = r;
		} r = x % y r x % y x y x = y x y y = r y r System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String[] str = new String[2];
		int count = 0; 
		while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		}
		
		String[] split = str[0].split(" ");
		int facter[];
		facter = new int[split.length];

		for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		}
		//swap
		if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		}
		
		int r = 0; 
		int x = facter[0];
		int y = facter[1];
		
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		System.out.println(x);
		
		
		
	}

} public class Main {
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String[] str = new String[2];
		int count = 0; 
		while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		}
		
		String[] split = str[0].split(" ");
		int facter[];
		facter = new int[split.length];

		for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		}
		//swap
		if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		}
		
		int r = 0; 
		int x = facter[0];
		int y = facter[1];
		
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		System.out.println(x);
		
		
		
	}

} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String[] str = new String[2];
		int count = 0; 
		while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		}
		
		String[] split = str[0].split(" ");
		int facter[];
		facter = new int[split.length];

		for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		}
		//swap
		if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		}
		
		int r = 0; 
		int x = facter[0];
		int y = facter[1];
		
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		System.out.println(x);
		
		
		
	}

}