fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val s = sc.next()

    val y: Set<String> = (100..199).map { it.toString().substring(1) }.toSet()
    val m: Set<String> = (101..112).map { it.toString().substring(1) }.toSet()

    val left = s.substring(0..1)
    val right = s.substring(2..3)

    val mmyy = m.contains(left) && y.contains(right)
    val yymm = m.contains(right) && y.contains(left)

    val r = if (yymm && mmyy) {
        "AMBIGUOUS"
    } else if (mmyy) {
        "MMYY"
    } else if (yymm) {
        "YYMM"
    } else {
        "NA"
    }

    println(r)

}