require 'date'

S = gets.chomp
first = S.slice(0..1)
last = S.slice(2..3)

date = '01'

# first - last
begin
  Date.parse("#{first}-#{last}-#{date}")
  f_l = true
rescue ArgumentError
  f_l = false
end


# last - first
begin
  Date.parse("#{last}-#{first}-#{date}")
  l_f = true
rescue ArgumentError
  l_f = false
end

if f_l && l_f
  puts 'AMBIGUOUS'
elsif f_l && !l_f
  puts 'YYMM'
elsif !f_l && l_f
  puts 'MMYY'
else
  puts 'NA'
end
