program kadai
	implicit none

	integer  ::  a,b,c
    integer  ::  flag1,flag2
    character(len=4)  ::  Q,X
    character(len=2)  ::  W
    character(len=9)  ::  Z
    flag1=0
    flag2=0
    
    read(*,*) a
    
    b=a/100
    c=a-b*100
    
    X="YYMM"
    Q="MMYY"
    Z="AMBIGUOUS"
    W="NA"
    if (0<c .and. c<13) then
    	flag1=1  !YYMM
    end if
    
    if (0<b .and. b<13) then
    	flag2=1  !MMYY
    end if
    
    if (flag1==0) then
    	if(flag2==1) then
        	write(*,'(a)') trim(Q)
        else
        	write(*,'(a)') trim(W)
        end if
    end if
    
    if (flag1==1) then
    	if(flag2==0) then
        	write(*,'(a)') trim(X)
        else
         	write(*,'(a)') trim(Z)
        end if
     end if
    
    
end program kadai