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