
fun main(args:Array<String>) {
    val S = readLine()!!
    val front = S.slice(0..1)
    val back = S.slice(2..3)

    assert(front.length == back.length)
    val maybe_mmyy =(Pair(front.toInt(), back.toInt())).let {
        val (f,b) = it
        f in 1..12 && b in 0..99 
    }

    val maybe_yymm =(Pair(front.toInt(), back.toInt())).let {
        val (f,b) = it
        f in 0..99 && b in 1..12 
    }


    when(Pair(maybe_mmyy, maybe_yymm)) {
        Pair(true,false) -> "MMYY"
        Pair(false,true) -> "YYMM"
        Pair(true,true) -> "AMBIGUOUS"
        else -> "NA"
    }.run(::println)
}
 