a,b,c,d=list(map(int,input().split())) s=0 n=d-c+1 for i in range(a,b+1): if i>=c and i<=d: s+=n-1 else: s+=n print(s)