A, B, C, D = map(int, input().split())
L = []
for i in range(A, B+1):
    for j in range(C, D+1):
        if i != j:
            l = (i,j)
            L.append(l)
L2 = []
ans = len(L)
for i in range(len(L)):
    if not L[i] in L2:
        L2.append(L[i]) 
    else:
        ans -= 1
print(ans)