A, B, C, D = map(int, input().split()) ans = 0 for i in range(A, B): if i >= C and D <= i: ans += D - C else: ans += D - C + 1 print(ans)