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

~/algor $ cat problems/if-oraliqqa-keltirish

Clamp to a range

Easy 1000 ms 64 MB 21%
Share

Integers $L$, $R$ ($L \le R$) and $x$ are given. Clamp $x$ to the range $[L; R]$: if $x < L$, take $L$; if $x > R$, take $R$; otherwise take $x$ itself.

A number is clamped to the bounds of the given range

Input

One line with three integers: $L$, $R$ and $x$.

Output

One integer — the value in the range.

Note

$-10^{9} \le L \le R \le 10^{9}$
$-10^{9} \le x \le 10^{9}$

Examples

Input #1
2 7 9
Output #1
7
Input #2
2 7 4
Output #2
4

Sign in to submit a solution

Signing up is free and takes a minute.