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

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            int p,c=0,br=1;
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (n <= 26) Console.WriteLine(0);
            else
            {
                for (int i = 1; i < s.Length; i++)
                {
                    p = s[i] - 'A';
                    if (p == s[i-1]-'A') c = 2;
                    else
                    {
                      if (p == (s[i - 1] - 'A') + 1)
                          br++;    
                    }
                }
                if (c == 2 && br == 26)
                    Console.WriteLine(2);
                else if (c != 2 && br == 25)
                    Console.WriteLine(1);
                 else Console.WriteLine(0);
            }
        }
    }
}