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[] raspored = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ0".ToCharArray();
            string red = Console.ReadLine();
            bool[] azb = new bool[n];
            if (red[0] == 'A')
                azb[0] = true;
            if (red[n-1] == 'Z')
                azb[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(raspored[Array.IndexOf(raspored, red[i]) - 1]) || red[i] == 'A') && ((pom2.Contains(raspored[Array.IndexOf(raspored, red[i]) + 1]) || red[i] == 'Z')))
                    azb[i] = true;
            }
            List<char> novi = new List<char>();
            for(int i = 0;i<n;i++)
            {
                if (azb[i])
                    nova.Add(red[i]);
            }
            char[] array = novi.ToArray();
            long p = 1;
            for(int i = 1;i<raspored.Length-1;i++)
            {
               p*= Array.FindAll<char>(array,x=> x==raspored[i]).Length % 1000000007;
            }
            Console.WriteLine((p % 1000000007));
        }
    }
}