Farmer John has $N$ rectangular barns ($1 \le N \le 25000$) on his farm. Every barn has sides parallel to the $x$- and $y$-axes, and its corner coordinates are integers between $0$ and $1{,}000{,}000$. The barns do not overlap, although they may share corners and/or sides with one another.
Because he has more cows to milk this year, Farmer John wants to expand some of his barns. A barn has room to expand only if it does not share a corner or a wall with any other barn — that is, all four of its walls can be pushed outward by at least some small amount without bumping into another barn. If two barns meet at a single corner, neither of them can expand.
Determine how many barns have room to expand.
In the example, only the first two barns listed can expand. Each of the other three barns touches at least one other barn at a corner or along a wall, so none of them can expand.