def g(x): return C[3]*x*x*x+C[2]*x*x+C[1]*x+C[0] def f(x): global a, b, c return a*x*x+b*x+c import sys input = sys.stdin.readline C = list(map(int, input().split())) L, R = map(int, input().split()) if L==R: print(g(L)) exit() # ax^2+bx+c=0 c, b, a = C[1], C[2]*2, C[3]*3 D = b*b-4*a*c if D<0: # 実数解なし # 単調 v = f(L) if v>=0: # 増加 l = g(L) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) elif D>0: if a==0: # 1個 x = -c/b if R<=x: # L, R, x # 単調 v = f(L) if v>=0: # 増加 l = g(L) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) elif x<=L: # x, L, R # 単調 v = f(R) if v>=0: # 増加 l = g(L) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) else: # L, x, R # L=0: # 増加 l = g(L) r = g(x) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(x) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) # x=0: # 増加 l = g(x) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = min(ans, abs(l)) else: ans = min(ans, abs(r)) else: # 減少 l = g(x) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = min(ans, abs(r)) else: ans = min(ans, abs(l)) else: # 実数解あり x1 = (-b+D**0.5)/(2*a) x2 = (-b-D**0.5)/(2*a) if x1>x2: x1, x2 = x2, x1 if L<=x1: if R<=x1: # L, R, x1, x2 # 単調 v = f(L) w = f(R) if v>0 or w>0: # 増加 l = g(L) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) elif x2=0: # 増加 l = g(L) r = g(x1) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(x1) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) # x1=0: # 増加 l = g(x1) r = g(x2) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = min(ans, abs(l)) else: ans = min(ans, abs(r)) else: # 減少 l = g(x1) r = g(x2) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = min(ans, abs(r)) else: ans = min(ans, abs(l)) # x2=0: # 増加 l = g(x2) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = min(ans, abs(l)) else: ans = min(ans, abs(r)) else: # 減少 l = g(x2) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = min(ans, abs(r)) else: ans = min(ans, abs(l)) else: # L, x1, R, x2 # L=0: # 増加 l = g(L) r = g(x1) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(x1) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) # x1=0: # 増加 l = g(x1) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = min(ans, abs(l)) else: ans = min(ans, abs(r)) else: # 減少 l = g(x1) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = min(ans, abs(r)) else: ans = min(ans, abs(l)) elif x2<=L: # x1, x2, L, R # 単調 v = f(L) w = f(R) if v>0 or w>0: # 増加 l = g(L) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) else: if x2=0: # 増加 l = g(L) r = g(x2) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(x2) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) # x2=0: # 増加 l = g(x2) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = min(ans, abs(l)) else: ans = min(ans, abs(r)) else: # 減少 l = g(x2) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = min(ans, abs(r)) else: ans = min(ans, abs(l)) else: # x1, L, R, x2 # 単調 v = f(L) w = f(R) if v>0 or w>0: # 増加 l = g(L) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) else: # 1個 # 単調 v = f(L) w = f(R) if v>0 or w>0: # 増加 l = g(L) r = g(R) if l<=0 and 0<=r: ans = 0 else: if l>0: ans = abs(l) else: ans = abs(r) else: # 減少 l = g(L) r = g(R) if r<=0 and 0<=l: ans = 0 else: if l>0: ans = abs(r) else: ans = abs(l) print(ans)