def resolve():
    S = input()

    # YY: 00<=YY<=99
    # MM: 01<=MM<=12
    
    f_canYY = lambda x: '00' <= x and x <= '99'
    f_canMM = lambda x: '01' <= x and x <= '12'

    a = S[0:2]
    b = S[2:4]

    yymm = f_canYY(a) and f_canMM(b)
    mmyy = f_canMM(a) and f_canYY(b)

    if yymm and mmyy:
        print('AMBIGUOUS')
    elif yymm and not mmyy:
        print('YYMM')
    elif not yymm and mmyy:
        print('MMYY')
    else:
        print('NA')

resolve()