A,B,C,D = map(int,input().split()) cnt = 0 for i in range(A,B+1): cnt += len([j for j in range(C,D+1) if i!=j]) print(cnt)