#P8382. [POI 2004] Gra

[POI 2004] Gra

Problem Description

Let us consider a game played on an m×1m \times 1 board, whose cells are numbered from 11 to mm.

There are nn pieces on the board. Each piece occupies exactly one cell, and no piece occupies cell mm.

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 mm wins.

We say that a move by the current player is a winning\text{winning} 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 winning\text{winning} moves.

Input Format

The first line contains two integers m,nm, n.

The next line contains nn strictly increasing integers, representing the indices of the initially occupied cells.

Output Format

Output the number of winning\text{winning} moves available to the first player.

5 2
1 3
1

Hint

For 100%100\% of the testdata: 2m1092 \le m \le 10^{9}, 1n1061 \le n \le 10^{6}, and n+1mn + 1 \le m.

Here is an example:

When m=7m = 7, a player can move 22 to 44, move 33 to 44, or move 66 to 77.

Translated by ChatGPT 5