Bob is decorating a loft-style rectangular wall with bricks. The wall consists of $n \times m$ unit cells. Some cells are already occupied by bricks, while the remaining cells are empty.

Bob wants to add up to two more bricks to this wall. New bricks must have a width equal to $1$ unit and can have any positive integer length. Each brick can only be placed horizontally or vertically, so each new brick will occupy several consecutive empty cells in one row or in one column. Also, these two bricks must not intersect, i.e. occupy the same cell.

What is the maximum possible sum of lengths of at most two new bricks that Bob can add to this wall?