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: ans = f(C-L-2*A-2*B+2, -C-L+1, R) - f(C-L-2*A-2*B+2, -C-L+1, L+C-1) ans %= 998244353 print(ans) else: ans = f(-B-L-A+1, -B-L-A+2, R) - f(-B-L-A+1, -B-L-A+2, L+A+B-1) ans %= 998244353 print(ans)