s = gets.chomp
f = s[0, 2].to_i
b = s[2, 2].to_i

def y(x)
  0 <= x && x <= 99
end

def m(x)
  1 <= x && x <= 12
end

ans = []
ans << 'YYMM' if y(f) && m(b)
ans << 'MMYY' if m(f) && y(b)

case ans.size
when 0
  puts 'NA'
when 1
  puts ans[0]
when 2
  puts 'AMBIGUOUS'
end
