Under construction

Still being built. Things may change

False Alarm

Time limit2sMemory limit2048 MB

Summary
Given n alarm times between 7:00 and 9:00, find the fewest extra alarms needed so that some three alarms fall within 10 minutes of each other.
Level

Easy2 of 10

Topics
Implementation, Brute force
Solved
No attempts yet

Problem

Faina is going to sleep, but she needs to wake up early tomorrow for a very important contest. She has already set nn alarms at different times between 7:00 and 9:00 in the morning.

However, Faina is a deep sleeper. To wake up, she needs to hear at least three alarms within a 10-minute span. In other words, for some three alarms, the difference between the first and the last alarm must be 10 minutes or less.

Faina is not sure whether her current alarms meet this condition, and she worries she might oversleep the contest and anger her teammates. So she wants to set some additional alarms. All new alarms must also be set between 7:00 and 9:00, and all alarms, including the old ones, must be at different times.

Find the smallest number of additional alarms Faina has to set to be confident that she will wake up. If she is already sure to wake up, the answer is 00.

Input

The first line contains a single integer nn, the number of alarms Faina has set (1≤n≤201 \le n \le 20).

The ii-th of the following nn lines contains the time of the ii-th alarm in the h:mm format (7≤h≤97 \le h \le 9; 00≤mm≤5900 \le mm \le 59; if h=9h = 9, then mm=00mm = 00). The alarms are given in strictly increasing order of time.

Output

Print the smallest number of additional alarms Faina has to set to guarantee that she wakes up.

Hint

In the first test, the three alarms at 7:56, 7:59, and 8:05 guarantee that Faina will wake up.

In the second test, any time between 8:00 and 9:00 that does not coincide with an existing alarm works.

In the third test, one possible solution is to set two more alarms at 7:45 and 7:46.

Examples3

  1. Example 1

    Input
    5
    7:47
    7:56
    7:59
    8:05
    8:13
    
    Expected output
    0
    
  2. Example 2

    Input
    7
    8:00
    8:10
    8:20
    8:30
    8:40
    8:50
    9:00
    
    Expected output
    1
    
  3. Example 3

    Input
    3
    7:13
    7:41
    8:36
    
    Expected output
    2