S = gets.chomp

s1, s2 = S[0 .. 1], S[2 .. 3]
mr = '01' .. '12'
puts case
     when mr.member?(s1) && !mr.member?(s2); "MMYY"
     when mr.member?(s2) && !mr.member?(s1); "YYMM"
     when mr.member?(s1) && mr.member?(s2); "AMBIGUOUS"
     else ; "NA"
end