r, c = gets.split.map &:to_i sy, sx = gets.split.map &:to_i gy, gx = gets.split.map &:to_i puts (sy - gy).abs + (sx - gx).abs