a, b, c, d = io.read("*n", "*n", "*n", "*n") if(b < c) then print((b - a + 1) * (d - c + 1)) elseif(a <= c) then if(b <= d) then print((c - a) * (d - c + 1) + (b - c + 1) * (d - c)) else print((d - c + 1) * (b - a)) end elseif(b < d) then print((b - a + 1) * (d - c)) elseif(a <= d) then print((d - a + 1) * (d - c) + (b - d) * (d - c + 1)) else print((b - a + 1) * (d - c + 1)) end