Farmer John has always done his best to keep his pastures full of luscious, delicious, healthy grass for his cows. He has lost this battle, though: the invasive milkweed has taken a foothold in the northwest corner of his farm.
The pasture is partitioned into a rectangular grid of height $Y$ ($1 \le Y \le 100$) and width $X$ ($1 \le X \le 100$). Cell $(1, 1)$ is the lower-left corner, so the grid uses ordinary $(x, y)$ coordinates. The milkweed starts growing in cell $(M_x, M_y)$.
Each week the milkweed spreads from every cell it already occupies into all of the (up to eight) surrounding non-boulder cells — the four orthogonal neighbors and the four diagonal neighbors. After spending just one week in a cell, the milkweed is ready to spread out of that cell as well.
Bessie wants to graze for as long as she can before the milkweed takes over, so she wonders how long the pasture will last. If the milkweed occupies cell $(M_x, M_y)$ at week $0$, in which week does it finish covering every non-boulder cell of the pasture? (For every input in this problem, the milkweed always ends up covering the whole pasture.)
The pasture is drawn with . for grass and * for a boulder. For example, with $X = 4$ and $Y = 3$:
....
..*.
.**.
If the milkweed starts in the lower-left corner (row $1$, column $1$), the map fills in as shown below. The five snapshots are weeks $0$ through $4$ from left to right, and M marks a milkweed-covered cell:
.... .... MMM. MMMM MMMM
..*. MM*. MM*. MM*M MM*M
M**. M**. M**. M**. M**M
The milkweed has covered the entire field after $4$ weeks.
. for grass and * for a boulder. Because $(1, 1)$ is the lower-left corner, line $k$ (for $2 \le k \le Y+1$) describes row $Y+2-k$.