readInt :: String -> Int
readInt = read
x ? (a,b) = if x then a else b

main = do
    s <- readInt<$>getLine
    putStrLn $ solve s

solve :: Int -> String
solve s = abnm?(cdnm?("NA","YYMM"), cdnm?("MMYY","AMBIGUOUS")) where
  abnm = nm ab
  cdnm = nm cd
  nm n = n == 0 || n > 12
  ab = div s 100
  cd = mod s 100
