using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            int br = 0;
            if (n < 26)
                br = 0;
            else if (n == 26)
            {
                if (str == s)
                    br = 1;
            }
            else if (n == 27)
            {
                int j = -1;
                bool b = true;
                for (int i = 0; i < 26 && b; i++)
                {
                    if (str[i] == str[i + 1] && j == -1)
                        j = i;
                    else if (j != -1 && str[i]==str[i+1])
                        b = false;
                }
                if (j == -1) b = false;
                if (b)
                {
                    string st = str.Remove(j, 1);
                    if (st == s)
                        br = 2;
                    else br = 0;
                }
                if (!b)
                {
                    bool b1 = true;
                    for (int i = 0; i < 28 && b1; i++)
                    {
                        string st = str.Remove(i, 1);
                        if (st == s)
                        {
                            br = 1;
                            b1 = false;
                        }
                    }
                }
            }
            else br = 5;
            Console.WriteLine(br);
        }
    }
}