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