A,B,C,D=map(int,input().split()) X=set(range(A,B+1)) Y=set(range(C,D+1)) print(len(X-Y)*len(Y-X)+len(X & Y)*(len(X & Y)-1))