S = gets.chomp

def is_probably_month?(i)
  return i > 0 && i < 13
end

puts begin
  S.yield_self do |s|
    break "NA" unless S =~ /^[0-9]{4}$/
    head, tail = [ s[0..1], s[2..3] ].map(&:to_i)
    break "AMBIGUOUS" if is_probably_month?(head) && is_probably_month?(tail)
    break "MMYY" if is_probably_month?(head)
    break "YYMM" if is_probably_month?(tail)
    "NA"
  end
end
