A, B, C, D = map(int, input().split()) set1 = set(range(A, B+1)) set2 = set(range(C, D+1)) ctr = 0 for num in set1: if num in set2: ctr += len(set2)-1 else: ctr += len(set2) print(ctr)