a,b,c,d=gets.split.map &:to_i cnt=0 for i in a..b for j in c..d if i!=j;cnt+=1;end end end puts cnt