def f(L): if L < 0: return 0 return (L+1)*(L+2)*(L+3)//6%998244353 L,R = map(int, input().split()) A,B,C = map(int, input().split()) N = R-L if A+B >= C: print(f(N-A-B)) exit() C -= A+B N -= A+B if N < C: print(0) else: print((f(N)-f(C-1)-C*(C+1)*(N-C+1)//2)%998244353)