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