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

~/algor $ cat problems/ikki-kesmaning-birida

In one of two segments?

Easy 1000 ms 64 MB 14%
Share

Two segments $[a; b]$, $[c; d]$ and a number $x$ are given on the number line. The ends of a segment belong to it too. Check whether the statement is true: “the number $x$ lies in at least one of the segments”.

Two segments and a point x on the number line; the point is inside one of the segments

Input

One line with five integers: $a$, $b$, $c$, $d$ and $x$.

Output

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

Note

$-10^{9} \le a \le b \le 10^{9}$
$-10^{9} \le c \le d \le 10^{9}$
$-10^{9} \le x \le 10^{9}$

Examples

Input #1
1 4 7 9 8
Output #1
1
Input #2
1 4 7 9 5
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.