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