S = gets.chomp
s1 = S[0, 2].to_i
s2 = S[2, 2].to_i

yymm = s2.between?(1, 12)
mmyy = s1.between?(1, 12)
ans = if yymm && mmyy
    "AMBIGUOUS"
elsif yymm
    "YYMM"
elsif mmyy
    "MMYY"
else
    "NA"
end
puts ans