'use strict'
function Main(input) {
    input = input.split("\n")[0].split('')
    let fore = input[0] + input[1]
    let back = input[2] + input[3]

    fore = parseInt(fore)
    back = parseInt(back)

    const isYear = (num) => {
      return 0 <= num && num < 100
    }
    const isMonth = (num) => {
       return 0 < num && num < 13 
    }
    
    const isForeYY = isYear(fore)
    const isBackYY = isYear(back)
    const isForeMM = isMonth(fore)
    const isBackMM = isMonth(back)
    
    const isYYMM = isForeYY && isBackMM
    const isMMYY = isForeMM && isBackYY

     let result = ""

    if(isYYMM && isMMYY ){
       result =  'AMBIGUOUS'
    } else if (isYYMM) {
      result =  'YYMM'
    } else if (isMMYY) {
      result = 'MMYY'
    } else {
      result = 'NA'
    }
    


    console.log(result)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))