A, B, C, D = map(int, input().split()) R = [i for i in range(A, B+1)] B = [i for i in range(C, D+1)] ans = 0 for r in R: for b in B: if r != b: ans += 1 print(ans)