 r = gets.split("")
 k = (r[0].to_s+r[1].to_s).to_i
 t = (r[2].to_s+r[3].to_s).to_i
if k == 0 || t ==0
    puts "NA"
elsif k <= 12 && t <= 12
    puts "AMBIGUOUS"
elsif k <= 12 && t <= 31
    puts "YYMM"
elsif t <= 12 && k <= 31
    puts "MMYY"
else
    puts "NA"
end
       