A,B,C,D=map(int,input().split()) ans=0 for a in range(A, B+1): if C<=a<=D: ans+=D-C else: ans+=D-C+1 print(ans)