Apprentice Learning Trajectory#9580

Apprentice Learning Trajectory

2 seconds
256 megabytes
Medium

Abigail is an apprentice studying to become a blacksmith. She wants to plan her learning trajectory and make as many swords as possible on her way to becoming a famous expert.

There are masters willing to host her as their apprentice. The -th master will start working at the minute a_i and end working at the minute b_i, working for a total of b_i - a_i minutes. During this interval of time, Abigail can work at this master's forge. She can enter and leave the forge several times and produce one or several swords upon each arrival. However, in order to produce a sword under supervision of the -th master she has to work there for t_i minutes in a row. She can't leave the sword unfinished and continue working on it upon her next arrival to this forge.

Help Abigail make an optimal plan and calculate the maximum number of swords she can produce under the supervision of masters.

Input

The first line contains integer n~(1 \le n \le 2 \cdot 10^5) — the number of masters.

Each of the next lines contains three integers a_i, b_i, t_i~(1 \le a_i < a_i + t_i \le b_i \le 10^{18}) — the start and the end time of master's work, and the time needed to make one sword in their forge.

Output

Output the maximum number of swords Abigail can produce using the optimal learning trajectory.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading