Polish version    English version  
  History of OI


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
XI Olympiad in Informatics 2003/2004

Task: gra

Game

I stage competition  
Source file: gra.xxx (xxx=pas,c,cpp)
Memory limit: 32 MB

Let us consider a game on a rectangular board m x 1 consisting of m elementary squares numbered successively from 1 to m. There are n pawns on the board, each on a distinct square. None of them occupies the square with number m. Each single move in the is the following action: the moving player picks a pawn from any occupied square chosen at will and places it on the first unoccupied square with a larger number. The two players make moves in turn. The one who puts a pawn on the last square, i.e. the square with a number m, wins.

In the case presented in the figure (m = 7), a player is allowed to move a pawn from square no. 2 to 4, from square no. 3 to 4 or from square no. 6 to 7. The latter ends the game.

Example

We say a player's move is winning if after making it he can win the game, no matter what moves his opponent makes.

Task

Write a programme that:

  • reads the size of a board and the initial setup of pawns from the standard input,
  • determines the number of distinct winning moves the starting player may choose in the given initial situation,
  • writes the result to the standard output.

Input

The first line of the input contains two integers m and n (2 <= m <= 109, 1 <= n <= 106, n < m) separated by a single space. The second line contains n increasing numbers - these are the numbers of squares the pawns are set on. Numbers in the line are separated by single spaces.

Output

The first and only output line should contain the number of distinct winning moves possible for the starting player in the given initial situation.

Example

For the following input data:

5 2
1 3

the correct answer is:

1

For the following input data:

5 2
2 3

the correct answer is:

0



Print friendly version