integer K
integer mae,ushiro
read*,K
mae=K/100
ushiro=mod(K,100)
if(check(mae).and.check(ushiro))then
  print"(A)","AMBIGUOUS"
else if(check(mae))then
  print"(A)","MMYY"
else if(check(ushiro))then
  print"(A)","YYMM"
else
  print"(A)","NA"
end if

contains
function check(x)
integer x
logical check
check=.true.
if(x==0.or. x>12)check=.false.
end function
end