import Control.Applicative

main = do
  s <- getLine
  putStrLn $ case s of
    s
      | isMatchMonth first &&
        isMatchYear first &&
        isMatchMonth second &&
        isMatchYear second -> "AMBIGUOUS"
      | isMatchMonth first &&
        isMatchYear second -> "MMYY"
      | isMatchYear first &&
        isMatchMonth second -> "YYMM"
      | otherwise -> "NA"
      where
        first = read $ take 2 s
        second = read $ drop 2 s

isMatchMonth::Int -> Bool
isMatchMonth x
  | x <= 0 = False
  | x <= 12 = True
  | otherwise = False

isMatchYear::Int -> Bool
isMatchYear x
  | x < 0 = False
  | x <= 99 = True
  | otherwise = False
  