Where to go?
Don't assume that Vasya spent all his time solving problems at the 2012 Olympics in London. Like most fans, he attended the Olympics to watch the competitions, solving problems only in his spare time.
As a fan, Vasya aimed to attend as many competitions as possible, especially in the sports he enjoyed. Fortunately, the schedule for all the events was available online. However, Vasya realized that simply attending the first available competition might not be the best strategy, as it could limit the number of competitions he could watch. Being a dedicated fan, Vasya took his viewing seriously: once he started watching a competition, he would stay until it ended. He was also relieved to know that all competitions concluded on the same day they began.
Your task is to help Vasya plan his schedule to attend the maximum number of competitions during his time at the Olympics.
Input
The first line of the input specifies the number of competitions Vasya is interested in, n (1 ≤ n ≤ 100000). The following n lines list the competitions, each described by the start time in the format hh:mm (00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59), followed by the end time in the same format, and the day d on which the competition takes place (1 ≤ d ≤ 30). Assume all competitions are held at the same location, so Vasya does not need time to move between them. Also, Vasya can attend a competition that starts at the exact time the previous one ends.
Output
Output a single number: the maximum number of competitions Vasya can attend.