a,b,c,d = map(int, input().split()) print(sum(1 for i in range(1,b+1) for j in range(c,d+1) if i != j))