Common Prime

3

4 votes
Algorithms, Easy, String Manipulation
Problem

Given two numbers A and B, find the smallest prime number that divides both of them or state that such number does not exist.

Input

First and only line of input contains two integers A and B.

Output

Print the smallest common prime divisor of A and B or 1 if it does not exist.

Constraints

1A,B1015

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

3 is the smallest common prime factor of 3 and 6.

Editor Image

?