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