import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Data.STRef

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  as <- replicateM m $ readLn :: IO [Int]
  print ((solve (listArray (1,m) as) n m) ! n)

solve :: UArray Int Int -> Int -> Int -> UArray Int Int
solve xs n m = runSTUArray $ do
  dptbl <- newArray (1,n) 0
  ref <- newSTRef 1
  forM_ [1..n] $ \i -> do
    p <- readSTRef ref

    if i == (xs!p)
      then writeArray dptbl i 0 >> writeSTRef ref (if p==m then p else (p+1))
      else case i of
             1 -> writeArray dptbl 1 1
             2 -> writeArray dptbl 2 2
             _ -> liftM2 (+) (readArray dptbl (i-1)) (readArray dptbl (i-2)) >>= writeArray dptbl i
    
  return dptbl
