using System;
using System.Collections.Generic;
using System.Linq;
namespace Treci
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            char[] redosled = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ0".ToCharArray();
            string red = Console.ReadLine();
            bool[] pravilni = new bool[n];
            if (red[0] == 'A')
                pravilni[0] = true;
            if (red[n-1] == 'Z')
                pravilni[n-1] = true;
            for (int i = 1;i<n-1;i++)
            {
                string pom = red.Substring(0, (i));
                string pom2 = red.Substring((i + 1), n-1-i);
                if ((pom.Contains(redosled[Array.IndexOf(redosled, red[i]) - 1]) || red[i] == 'A') && ((pom2.Contains(redosled[Array.IndexOf(redosled, red[i]) + 1]) || red[i] == 'Z')))
                    pravilni[i] = true;
            }
            List<char> nova = new List<char>();
            for(int i = 0;i<n;i++)
            {
                if (pravilni[i])
                    nova.Add(red[i]);
            }
            char[] niz = nova.ToArray();
            long p = 1;
            for(int i = 1;i<redosled.Length-1;i++)
            {
               p*= Array.FindAll<char>(niz,x=> x==redosled[i]).Length % 1000000007;
            }
            Console.WriteLine((p % 1000000007));
        }
    }
}