1.

package acm_653_gizlich;

import java.util.Scanner;

/**
* FWP, Ausgew¦hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: acm_653_gizlich
* Link:
*
* @author Martin Lambeck
* @version 1.0, 07.09.2010
*
* Method : backtracking
* Status : Accepted
* Runtime: 0.382
*/


public class Main
{
static Scanner sc = new Scanner(System.in);
static boolean bothOK = false;
static boolean firstOK = false;

public static void main(String... args)
{
while (sc.hasNextInt())
testcase();
}

public static void testcase()
{
int s1 = sc.nextInt();
int s2 = sc.nextInt();

if (s1 > s2)
{
int tmp = s2;
s2 = s1;
s1 = tmp;
}

bothOK = false;
firstOK = false;


bt(s1, s2, 2);

if (bothOK || !firstOK)
System.out.println(s2);
else
System.out.println(s1);

}

static void bt (int s1, int s2, int d)
{
if ((s1 == 1) && (s2 == 1))
bothOK = true;

if (s1 == 1)
firstOK = true;

for (; (d <= 100) && !bothOK; d++)
{
if ((s1 != 1) && (s1 % d == 0))
bt(s1 / d, s2, d+1);

if (!bothOK && (s2 != 1) && (s2 % d == 0))
bt(s1, s2 / d, d+1);
}
}
}