#P8382. [POI 2004] Gra
[POI 2004] Gra
Problem Description
Let us consider a game played on an board, whose cells are numbered from to .
There are pieces on the board. Each piece occupies exactly one cell, and no piece occupies cell .
Each move follows these rules: the player chooses one piece and moves it to the first unoccupied cell with a larger index than its current cell. The two players move alternately. The first player to occupy cell wins.
We say that a move by the current player is a move if, after making this move, the other player cannot win no matter what they do.
We want to know how many first moves of the first player are moves.
Input Format
The first line contains two integers .
The next line contains strictly increasing integers, representing the indices of the initially occupied cells.
Output Format
Output the number of moves available to the first player.
5 2
1 3
1
Hint
For of the testdata: , , and .
Here is an example:

When , a player can move to , move to , or move to .
Translated by ChatGPT 5