On the southern slope of a mountain there are several ski tracks and a single ski lift. Every track runs from the top station of the lift down to the bottom station. Each morning a team of lift workers inspects the tracks: they ride the lift up together to the top station, and then each worker skis down to the bottom station along a track of their own choosing. Every worker skis down exactly once. Different workers' routes may share sections. Every route always leads downwards.
The ski area is a network of clearings joined by cuttings through the forest. Every clearing sits at a distinct height, and any two clearings are joined by at most one cutting. Skiing from the top to the bottom, a worker can pass through any clearing (though not necessarily all of them in a single run). Routes meet only at clearings; there are no tunnels or bridges.
A cutting is inspected when at least one worker skis along it. The workers want to inspect every cutting between the clearings using as few workers as possible.
Write a program that reads the map of ski tracks and computes the minimum number of workers whose routes together cover every cutting.
The first line contains one integer n, the number of clearings (2≤n≤5000). The clearings are numbered from 1 to n: clearing 1 is the top station of the lift and clearing n is the bottom station.
Each of the next n−1 lines describes the downward cuttings leaving one clearing. Line i+1 (for i from 1 to n−1) describes clearing i: it begins with an integer k, the number of cuttings that lead down from clearing i, followed by the numbers of the k clearings they lead to, listed from west to east in the order the cuttings are arranged.
Output a single integer: the minimum number of workers whose routes together inspect every cutting in the forest.