P1607 [USACO09FEB] Fair Shuttle G

Description

Although Farmer John has no problems walking around the fair to collect prizes or see the shows, his cows are not in such good shape; a full day of walking around the fair leaves them exhausted. To help them enjoy the fair, FJ has arranged for a shuttle truck to take the cows from place to place in the fairgrounds. FJ couldn't afford a really great shuttle, so the shuttle he rented traverses its route only once (!) and makes N (1

Input Format

The first line: contains three integers: $K, N$ and $C$, separated by spaces. The second line to the $K+1$ line: in the $i+1$ line, it will tell you the information of the $i$th group of cows: $S_i, E_i$ and $M_i$, separated by spaces.

Output Format

First row: The maximum number of cows that can take the bus.

Explanation/Hint

The shuttle bus can take $2$ cows from $1$ to $5$, $3$ cows from $5$ to $8$, $2$ cows from $8$ to $14$, $1$ cows from $9$ to $12$, $1$ cows from $13$ to $14$, and $1$ cows from $14$ to $15$.