s = gets.chomp!

head = s[0, 2].to_i
tail = s[2, 2].to_i

case head
when 0
    head_mm = 0
when 1..12
    head_mm = 1
when 13..99
    head_mm = 2
end

case tail
when 0
    tail_mm = 0
when 1..12
    tail_mm = 1
when 13..99
    tail_mm = 2
end

case [head_mm, tail_mm]
when [0,0], [0,2], [2,0], [2,2]
    puts "NA"
when [0, 1], [2,1]
    puts "YYMM"
when [1,0], [1,2]
    puts "MMYY"
when [1,1]
    puts "AMBIGUOUS"
end
