CAMPA1 - CAMPANAS1

This problem is the first of a set based on the same problem statement ("How many times the bell rang?"), specifically designed to work with different approaches and types of solutions.

In this first problem, your solution must be done using simulation (see this Prezi, to get the meaning we are giving to this term). You can submit a solution done without respecting this requirement, and eventually, the judge will inform "Accepted". In this case, your solution will be disqualified later, in a manual way by the problem setter.

Problem Description

The priest of a church want to know the number of times the bell will ring during a specified time interval. This interval starts on h1:m1, and ends on h2:m2; where h1:m1 is the hour-minute of beginning, and h2:m2 is hour-minute of the end. The bell rings each 15 minutes: on the hour, 15 minutes past the hour, 30 minutes past the hour, and 45 minutes past the hour.

h1:m1 and h2:m2 are in the same day, and h1:m1 <= h2:m2.

Input

The input comes as a series of intervals, each in a different line. In each line there are four integers indicating hour and minute of the beginning and the end of the interval. The last line contains the values 0 0 0 0, indicating end of data and should not be processed.

In no case will be more than 100000 intervals in the input.

Output

The output to show in each input case, will be an integer indicating the number of times that the bell will ring.

Example

Input:
8 0 8 56
9 0 9 15
7 15 8 16
0 0 0 0

Output:
4
1
5

Author / Autor: Daniel Ambort


Added by:Coach UTN FRSF
Date:2013-02-18
Time limit:1s-2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU

hide comments
2018-06-21 09:18:07
Statement should mention that the bell rings every 15 minutes. BTW. I'd hate to live near that church.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.