import math

l, r = map(int, input().split())
ans = l**l
for i in range(l, r+1):
    num = int(i**i)
    ans = math.gcd(ans, num)
print(ans)