program bbb
implicit none

integer :: i, j, k, l
character(4) :: s

read*, s

if (s(1:1)=='0') then
 if (s(2:2)=='0') then
 write(*,'(a2)') 'NA'
 return
 else
 read(s(1:1),*) i
 end if
else
read(s(1:2),*) i
end if

if (s(3:3)=='0') then
 if (s(4:4)=='0') then
 write(*,'(a2)') 'NA'
 return
 else
 read(s(3:3),*) j
 end if
else
read(s(3:4),*) j
end if

if(i>=13.and.j>=13) write(*,'(a2)') 'NA'
if(i>=13.and.j<13) write(*,'(a4)') 'YYMM'
if(i<13.and.j>=13) write(*,'(a4)') 'MMYY'
if(i<13.and.j<13) write(*,'(a9)') 'AMBIGUOUS'

end program