a,b,c,d=map(int,input().split()) A=[i for i in range(a,b+1)] B=[i for i in range(c,d+1)] ans=0 for i in A: for j in B: if i!=j: ans+=1 print(ans)