Олимпиадный тренинг

Задача 38192. Metro


Vitya works near one of the stations of the Moscow metro circle line, but lives next to another station on the same line. It is required to find out what is the least number of intermediate stations that Vitya needs to pass along the ring in order to get home from work.

Input
The stations are numbered in a row with natural numbers 1, 2, 3, …, N (the 1st station – is adjacent to the Nth), N does not exceed 100.

Three numbers are entered: first N – the total number of stations on the circle line, and then i and j – the numbers of the station at which Vitya gets off, and the station at which he must get off. Numbers i and j do not match. All numbers are separated by a space.

Imprint
It is required to give the minimum number of intermediate stations (not counting the pick-up and drop-off stations) that Vitya needs to pass.

Examples
# Input Output Explanations
1 100 5 6 0 There are 100 stations on the circle line; Vitya can go from the 5th to the 6th station directly, without intermediate stations
2 10 1 9 1 There are 10 stations on the circle line; Vitya can go from the 1st to the 9th station through one intermediate station, its number is 10