import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = scan.nextInt();
	if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	}
	while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	}
	System.out.println(gcd(x, y));
    }
    static int gcd (int x, int y) {
	for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	}
	return 1;
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = scan.nextInt();
	if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	}
	while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	}
	System.out.println(gcd(x, y));
    }
    static int gcd (int x, int y) {
	for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	}
	return 1;
    }
} Main public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = scan.nextInt();
	if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	}
	while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	}
	System.out.println(gcd(x, y));
    } main {
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = scan.nextInt();
	if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	}
	while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	}
	System.out.println(gcd(x, y));
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	} x < y x y {
	    int tmp = y;
	    y = x;
	    x = tmp;
	} int tmp = y; tmp y y = x y x x = tmp x tmp while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	} x % y != 0 x % y x y 0 {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	} int tmp = y; tmp y y = x % y y x % y x y x = tmp x tmp System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y String[] args args static int gcd (int x, int y) {
	for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	}
	return 1;
    } gcd {
	for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	}
	return 1;
    } for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	} int i = x; int i = x; i x i > 0 i 0 i-- i-- i {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	} {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	} if (y % i == 0 && x % i == 0) {
		return i;
	    } y % i == 0 && x % i == 0 y % i == 0 y % i y i 0 x % i == 0 x % i x i 0 {
		return i;
	    } return i; i return 1; 1 int x x int y y public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = scan.nextInt();
	if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	}
	while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	}
	System.out.println(gcd(x, y));
    }
    static int gcd (int x, int y) {
	for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	}
	return 1;
    }
} public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = scan.nextInt();
	if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	}
	while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	}
	System.out.println(gcd(x, y));
    }
    static int gcd (int x, int y) {
	for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	}
	return 1;
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = scan.nextInt();
	if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	}
	while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	}
	System.out.println(gcd(x, y));
    }
    static int gcd (int x, int y) {
	for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	}
	return 1;
    }
}