from math import comb l, r = map(int, input().split()) a, b, c = map(int, input().split()) k = r - l - a - b d = c - a - b if k < 0: print(0) exit() ans = comb(k + 3, 3) if d > 0: ans -= - d * (d + 1) * (-3 * k + 2 * d - 5) // 6 print(ans % 998244353)