function main(input) {
  const inputChars = input.split("");
  const upper = parseInt(inputChars[0] + inputChars[1]);
  const lower = parseInt(inputChars[2] + inputChars[3]);
  var YYMM = false;
  var MMYY = false;

  const d1 = new Date(upper + 2000, lower - 1, 1);
  if (d1.getFullYear() == upper + 2000 && d1.getMonth() == lower - 1) {
    YYMM = true;
  }

  const d2 = new Date(lower + 2000, upper - 1, 1);
  if (d2.getFullYear() == lower + 2000 && d2.getMonth() == upper - 1) {
    MMYY = true;
  }

  if (YYMM && MMYY) {
    console.log("AMBIGUOUS");
    return
  }
  if (YYMM) {
    console.log("YYMM");
    return
  }
  if (MMYY) {
    console.log("MMYY");
    return
  }
  console.log("NA");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));