import random C = list(map(int, input().split())) L, R = map(int, input().split()) def f(x): return abs(C[0] + C[1] * x + C[2] * x * x + C[3] * x * x * x) ans = 1 << 60 for _ in range(10 ** 5): x = random.random() * (R - L) + L ans = min(ans, f(x)) print(ans)