package tw.LanYao.myproject.HomeWork;
import java.util.ArrayList;
import java.util.Scanner;
public class 查詢2數最大公因數 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sca1 = new Scanner(System.in);
while (sca1.hasNext()) {
int a = sca1.nextInt();
int b = sca1.nextInt();
ArrayList aa1 = new ArrayList();
ArrayList aa2 = new ArrayList();
int n = 0;
for (int i = 2; i <= a; i++) {
if (a % i == 0) {
aa1.add(i);
n++;
}
}
n = 0;
for (int i = 2; i <= b; i++) {
if (b % i == 0) {
aa2.add(i);
n++;
}
}
ArrayList ans = new ArrayList();
for (int i = aa1.size(); i > 0; i--) {
for (int n1 = aa2.size(); n1 > 0; n1--) {
if (aa1.get(i - 1) == aa2.get(n1 - 1)) {
ans.add(aa1.get(i - 1));
}
}
}
System.out.println(ans.get(0));
}
}
}