program main
  implicit none
  integer i, mae, ushiro
  character(4) S
  read(*, *) S
  mae = 0
  ushiro = 0
  if (S(1:1) == '0') then
    if (S(2:2) /= '0') then
      mae = 1
    endif
  else if (S(1:1) == '1') then
    if (S(2:2) == '0' .or. S(2:2) == '1' .or. S(2:2) == '2') then
      mae = 1
    endif
  end if
  
  if (S(3:3) == '0') then
    if (S(4:4) /= '0') then
      ushiro = 1
    endif
  else if (S(3:3) == '1') then
    if (S(4:4) == '0' .or. S(4:4) == '1' .or. S(4:4) == '2') then
      ushiro = 1
    endif
  end if

   
  if (mae == 1) then
    if (ushiro == 1) then
      write(*,'(A)') 'AMBIGUOUS'
    else
      write(*,'(A)') 'MMYY'
    end if
  else
    if (ushiro == 1) then
      write(*,'(A)') 'YYMM'
    else
      write(*,'(A)') 'NA'
    end if
  end if
          


end program main
