{-# LANGUAGE FlexibleContexts #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import qualified Data.Sequence as S
import Data.Maybe (isJust)
import Data.List (permutations,nub)

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

updArray arr i f = do
  a <- readArray arr i
  writeArray arr i (f a)

path (x:y:xs) es = (isJust $  y `S.elemIndexL` (es!x)) && path(y:xs) es
path _ _ = True

solve n es = length $ nub
  [last p |
    p <- permutations [2..n],
    path (1:p) es]

main = do
  [n,m] <- getInts
  arr <- newArray (1,n) S.empty :: IO (IOArray Int (S.Seq Int))
  replicateM_ m $ do
    [a,b] <- getInts
    updArray arr a (\s -> s S.|> b)
    updArray arr b (\s -> s S.|> a)
  es <- freeze arr :: IO (Array Int (S.Seq Int))
  print $ solve n es
