a, b, c, d = map( int, input().split()) ans = 0 for i in range(a,b+1): if c <= i and i <= d: ans += d-c else: ans += d-c+1 print(ans)