using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {

        

        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int s1 = int.Parse(S[0].ToString());
            int s2 = int.Parse(S[1].ToString());
            int s3 = int.Parse(S[2].ToString());
            int s4 = int.Parse(S[3].ToString());

            if(s1 >= 2)
            {
                //yymm
                if(s3 == 0)
                {
                    if(s4 != 0)
                    {
                        Console.WriteLine("YYMM");
                    }
                    else
                    {
                        Console.WriteLine("NA");
                    }
                }
                else if(s3 == 1)
                {
                    if(s4 <= 2)
                    {
                        Console.WriteLine("YYMM");
                    }
                    else
                    {
                        Console.WriteLine("NA");
                    }
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
            else if(s3 >= 2)
            {
                //mmyy
                if (s1 == 0)
                {
                    if (s2 != 0)
                    {
                        Console.WriteLine("MMYY");
                    }
                    else
                    {
                        Console.WriteLine("NA");
                    }
                }
                else if(s1 == 1)
                {
                    if(s2 <= 2)
                    {
                        Console.WriteLine("MMYY");
                    }
                    else
                    {
                        Console.WriteLine("NA");
                    }
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
            else
            {
                if(s1 == 1 && s3 == 1)
                {
                    if(s2 <= 2 && s4 <= 2)
                    {
                        Console.WriteLine("AMBIGUOUS");
                    }
                    else if(s2 <= 2)
                    {
                        Console.WriteLine("MMYY");
                    }
                    else if(s4 <= 2)
                    {
                        Console.WriteLine("YYMM");
                    }
                    else
                    {
                        Console.WriteLine("NA");
                    }
                }
                else if(s1 == 1 && s3 == 0)
                {
                    if(s2 > 2)
                    {
                        if(s4 != 0)
                        {
                            Console.WriteLine("YYMM");
                        }
                        else
                        {
                            Console.WriteLine("NA");
                        }                    
                    }
                    else if(s4 > 0)
                    {
                        Console.WriteLine("AMBIGUOUS");
                    }
                    else if(s4 == 0)
                    {
                        Console.WriteLine("MMYY");
                    }                  
                }
                else if(s1 == 0 && s3 == 1)
                {
                    if(s4 > 2)
                    {
                        if(s2 != 0)
                        {
                            Console.WriteLine("MMYY");
                        }
                        else
                        {
                            Console.WriteLine("NA");
                        }
                    }
                    else if(s2 > 0)
                    {
                        Console.WriteLine("AMBIGUOUS");
                    }
                    else if(s2 == 0)
                    {
                        Console.WriteLine("YYMM");
                    }                   
                }
                else
                {
                    if(s2 != 0 || s4 != 0)
                    {
                        if (s2 != 0 && s4 != 0)
                        {
                            Console.WriteLine("AMBIGUOUS");
                        }
                        else if(s2 == 0)
                        {
                            Console.WriteLine("YYMM");
                        }
                        else if(s4 == 0)
                        {
                            Console.WriteLine("MMYY");
                        }
                    }
                    else
                    {
                        Console.WriteLine("NA");
                    }                
                }
            }

            

        }
    }
}

Measured memory_bytes: 11092