s = gets()
begin
	Time.new(2000 + s[0 .. 1].to_i, s[2 .. 3].to_i, 1)
	yymm = true
rescue
	yymm = false
end

begin
	Time.new(2000 + s[2 .. 3].to_i, s[0 .. 1].to_i, 1)
	mmyy = true
rescue
	mmyy = false
end

puts (yymm ? (mmyy ? "AMBIGUOUS" : "YYMM") : (mmyy ? "MMYY" : "NA"))
