100 #ABC094B. [ABC094B] Toll Gates

[ABC094B] Toll Gates

Score : 200200 points

Problem Statement

There are N+1N + 1 squares arranged in a row, numbered 0,1,...,N0, 1, ..., N from left to right.

Initially, you are in Square XX. You can freely travel between adjacent squares. Your goal is to reach Square 00 or Square NN. However, for each i=1,2,...,Mi = 1, 2, ..., M, there is a toll gate in Square AiA_i, and traveling to Square AiA_i incurs a cost of 11. It is guaranteed that there is no toll gate in Square 00, Square XX and Square NN.

Find the minimum cost incurred before reaching the goal.

Constraints

  • 1N1001 \leq N \leq 100
  • 1M1001 \leq M \leq 100
  • 1XN11 \leq X \leq N - 1
  • 1A1<A2<...<AMN1 \leq A_1 < A_2 < ... < A_M \leq N
  • AiXA_i \neq X
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM XX

A1A_1 A2A_2 ...... AMA_M

Output

Print the minimum cost incurred before reaching the goal.

5 3 3
1 2 4
1

The optimal solution is as follows:

  • First, travel from Square 33 to Square 44. Here, there is a toll gate in Square 44, so the cost of 11 is incurred.
  • Then, travel from Square 44 to Square 55. This time, no cost is incurred.
  • Now, we are in Square 55 and we have reached the goal.

In this case, the total cost incurred is 11.

7 3 2
4 5 6
0

We may be able to reach the goal at no cost.

10 7 5
1 2 3 4 6 8 9
3