cho.sh
Notes
Loading...

Fence

Time limit

2s

Memory limit

128 MB

Problem

There is a beautiful garden with many trees in front of Eunjin's house.

A new law requires every garden to be surrounded by a fence. The fence must be an axis-aligned rectangle, and every tree that remains standing must be inside the fence or on its boundary.

Eunjin cannot afford to buy fence material, so she must cut down some of the trees in the garden and use them to build the fence. For each tree, its position (x, y) and the length of fence material obtained by cutting it down are given.

Because Eunjin loves trees, she wants to cut down as few trees as possible. Find the minimum number of trees she must cut down to satisfy the new law.

A rectangle may have width 0 or height 0. It is also considered a rectangle when both are 0.

Input

The first line contains a natural number N. N is between 2 and 40, inclusive.

Each of the next N lines contains, in order, the x coordinate of a tree, the y coordinate of the tree, and the length of fence material obtained by cutting down that tree.

Every value in the input is a natural number not greater than 1,000,000. No two trees have the same x coordinate, and no two trees have the same y coordinate.

Output

Print one line containing the minimum number of trees that must be cut down to satisfy the new law.