After several harsh winters, Farmer John has decided it is time to repaint his farm. The farm consists of $N$ fenced enclosures ($1 \le N \le 50{,}000$), each of which can be described by a rectangle in the 2D plane whose sides are parallel to the $x$- and $y$-axes.
An enclosure may be contained inside another enclosure, but no two fences ever intersect. Consequently, if two enclosures cover the same area of the plane, one of them must be completely contained within the other.
An enclosure contained inside another enclosure is hidden from the outside world, so Farmer John only wants to repaint the enclosures that are not contained within any other enclosure. Determine the total number of enclosures he needs to paint.
Because no two fences intersect, whenever two enclosures cover the same region one of them must lie entirely inside the other. You only need to count the enclosures that are not nested inside any other enclosure.