s = gets.chomp.chars
s_start = [s[0], s[1]]
s_end = [s[2], s[3]]
def search(x, y)
  if x == '0'
    if y.match(/[1-9]/)
      'Yes'
    else
      'No'
    end
  elsif x == '1'
    if y.match(/[0-2]/)
      'Yes'
    else
      'No'
    end
  else
    'No'
  end
end
a = search(s_start[0], s_start[1])
b = search(s_end[0], s_end[1])
if a == 'Yes' && b == 'Yes'
  puts 'AMBIGUOUS'
elsif a == 'Yes' && b == 'No'
  puts 'MMYY'
elsif a == 'No' && b == 'Yes'
  puts 'YYMM'
elsif a == 'No' && b == 'No'
  puts 'NA'
end
