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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            bool tacno = false;
            int a, b, br = 0;
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (n <= 26)
                Console.WriteLine(0);
            else if (n == 27)
            {
                for (int i = 1; i < n; i++)
                {
                    a = s[i - 1] - 'A';
                    b = s[i] - 'A';
                    if (b == a + 1)
                        br++;
                    if (a == b)
                        {
                            tacno = true; 
                        }
                }
                if (tacno && br == 25)
                    Console.WriteLine(2);
                else if (br == 24 && tacno == false)
                    Console.WriteLine(1);
                else
                    Console.WriteLine(0);
            }      
        }
    }
}