var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var S = lines[0];
    var result = S.match(/[0][1-9][2-9][0-9]/gi)
    //console.log(result, S)
    if (result !== null && result[0] === S) { console.log("MMYY"); return (0) }

    var result = S.match(/[1][1-2][2-9][0-9]/gi)
    //console.log(result, S)
    if (result !== null && result[0] === S) { console.log("MMYY"); return (0) }

    var result = S.match(/[2-9][0-9][0][1-9]/gi)
    //console.log(result, S)
    if (result !== null && result[0] === S) { console.log("YYMM"); return (0) }

    var result = S.match(/[2-9][0-9][1][1-2]/gi)
    //console.log(result, S)
    if (result !== null && result[0] === S) { console.log("YYMM"); return (0) }

    var result = S.match(/[1-9][3-9][0][1-9]/gi)
    //console.log(result, S)
    if (result !== null && result[0] === S) { console.log("YYMM"); return (0) }

    var result = S.match(/[1-9][3-9][1][1-2]/gi)
    //console.log(result, S)
    if (result !== null && result[0] === S) { console.log("YYMM"); return (0) }

    var result = S.match(/[0][0][0-9][0-9]/gi)
    //console.log(result, S)
    if (result !== null && result[0] === S) { console.log("NA"); return (0) }

    var result = S.match(/[0-9][0-9][0][0]/gi)
    console.log(result, S)
    if (result !== null && result[0] === S) { console.log("NA"); return (0) }


    console.log("AMBIGUOUS");
});