program yymm_or_mmyy
  implicit none
  character(4) :: s
  logical :: mmyy, yymm
  read(*,'(a)') s
  mmyy = "01" <= s(1:2) .and. s(1:2) <= "12"
  yymm = "01" <= s(3:4) .and. s(3:4) <= "12"
  if (yymm .and. mmyy) then
    write(*,'(a)') "AMBIGUOUS"
  else if (yymm) then
    write(*,'(a)') "YYMM"
  else if (mmyy) then
    write(*,'(a)') "MMYY"
  else
    write(*,'(a)') "NA"
  end if
end program yymm_or_mmyy