#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
    long long int n, res = 0, ponavljanje;
    std::string s;
    std::cin >> n >> s;
    std::vector<long int> finalRes;
    std::vector<char> slova(s.begin(), s.end());
    
    char curr = '$';
    for (int i = 0; i < n; i++)
    {
        if (slova[i] == curr) res++;
        else
        {
            ponavljanje = std::count(slova.begin(), slova.end(), curr);
            i = 0;
            n -= (ponavljanje);
            slova.erase(std::remove(slova.begin(), slova.end(), curr), slova.end());
            if (res != 0)
            {
                finalRes.push_back(res + 1);
                res = 0;
            }
        }
        curr = slova[i];
    }

    if (res != 0)
        finalRes.push_back(res + 1);
    res = 1;

    for (auto& x : finalRes)
    {
        res *= x;
    }

    if (res == 1) std::cout << 0;
    else std::cout << res; 
}