program bbb
implicit none

integer :: s, i, j

read*, s
i=s/100
j=s-i*100

if(i==0.and.j==0) then
write(*,'(a2)') 'NA'
return
end if

if(i==0) then
 if(j>12) 	write(*,'(a2)') 'NA'
 if(j<=12)  write(*,'(a4)') 'YYMM'
else if(j==0) then
 if(i>12)   write(*,'(a2)') 'NA'
 if(i<=12)  write(*,'(a4)') 'MMYY'
else
 if(i<=12.and.j<=12) write(*,'(a9)') 'AMBIGUOUS'
 if(i<=12.and.j>12) 	write(*,'(a4)') 'MMYY' 
 if(i>12.and.j<=12) 	write(*,'(a4)') 'YYMM'
 if(i>12.and.j>12) 	write(*,'(a2)') 'NA'
end if

end program