import java.util.Scanner;

public class Main {
private static Scanner scanner;

public static void main(String args[])
{
	scanner = new Scanner(System.in);
	int a = scanner.nextInt(),b = scanner.nextInt();
	if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	}
	System.out.println(b);
}
}

 import java.util.Scanner; Scanner java.util public class Main {
private static Scanner scanner;

public static void main(String args[])
{
	scanner = new Scanner(System.in);
	int a = scanner.nextInt(),b = scanner.nextInt();
	if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	}
	System.out.println(b);
}
} Main private static Scanner scanner; scanner public static void main(String args[])
{
	scanner = new Scanner(System.in);
	int a = scanner.nextInt(),b = scanner.nextInt();
	if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	}
	System.out.println(b);
} main {
	scanner = new Scanner(System.in);
	int a = scanner.nextInt(),b = scanner.nextInt();
	if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	}
	System.out.println(b);
} scanner = new Scanner(System.in) scanner new Scanner(System.in) int a = scanner.nextInt() a scanner.nextInt() scanner.nextInt scanner b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	} a < b a b {
		int tmp = a;
		a = b;
		b = tmp;
	} int tmp = a; tmp a a = b a b b = tmp b tmp while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	} a%b != 0 a%b a b 0 {
		int c = a%b;
		a = b;
		b = c;
	} int c = a%b; c a%b a b a = b a b b = c b c System.out.println(b) System.out.println System.out System System.out b String args[] args public class Main {
private static Scanner scanner;

public static void main(String args[])
{
	scanner = new Scanner(System.in);
	int a = scanner.nextInt(),b = scanner.nextInt();
	if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	}
	System.out.println(b);
}
} public class Main {
private static Scanner scanner;

public static void main(String args[])
{
	scanner = new Scanner(System.in);
	int a = scanner.nextInt(),b = scanner.nextInt();
	if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	}
	System.out.println(b);
}
} Main
import java.util.Scanner;

public class Main {
private static Scanner scanner;

public static void main(String args[])
{
	scanner = new Scanner(System.in);
	int a = scanner.nextInt(),b = scanner.nextInt();
	if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	}
	System.out.println(b);
}
}


