s = gets.chomp
ans = 'NA'
if (1..12).include? (s[0] + s[1]).to_i
    if (1..12).include? (s[2] + s[3]).to_i
        ans = 'AMBIGUOUS'
    else
        ans = 'MMYY'
    end
elsif (1..12).include? (s[2] + s[3]).to_i
    ans = 'YYMM'
end
puts ans