Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/dokon-ochiqmi

Is the shop open?

Medium 1000 ms 64 MB 43%
Share

Every day a shop opens at $h_{1}$ hours $m_{1}$ minutes and closes at $h_{2}$ hours $m_{2}$ minutes (in $24$-hour format). If the closing time is earlier than the opening time, the shop closes after midnight, on the next day: for example, from $22$ hours $0$ minutes to $2$ hours $0$ minutes. The shop is open at the opening minute and closed at the closing minute. Check whether the statement is true: “the shop is open at $h$ hours $m$ minutes”.

A 24-hour circle: the shop's opening hours are marked by an arc that may cross midnight; the given time lies on that arc

Input

The first line contains four integers: $h_{1}$, $m_{1}$, $h_{2}$ and $m_{2}$.
The second line contains two integers: $h$ and $m$.

Output

One integer: $1$ if the statement is true, otherwise $0$.

Note

$0 \le h_{1}, h_{2}, h \le 23$
$0 \le m_{1}, m_{2}, m \le 59$
The opening and closing times are different.

Examples

Input #1
22 0 2 0
1 30
Output #1
1
Input #2
9 0 18 0
18 0
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.