#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <utility>

std::vector<int> xs;
std::vector<int> os;

int xs_in(int from, int to)
{
    if (from == 0)
        return xs[to];
    else
        return xs[to] - xs[from-1];
}

int os_in(int from, int to)
{
    if (from == 0)
        return os[to];
    else
        return os[to] - os[from-1];
}

std::pair<bool, int> is_square(int x)
{
    double sq = std::sqrt(x);
    int sqi = static_cast<int>(sq);
    return {sqi * sqi == x, sqi};
}

bool is_tile(int from, int to)
{
    int xc = xs_in(from, to);
    int oc = os_in(from, to);

    auto xpair = is_square(xc);
    auto opair = is_square(oc);

    return xpair.first && (xpair.second * 4 + 4 == oc)
        || opair.first && (opair.second * 4 + 4 == xc);
}


int main() {
    std::string line;
    int N;
    std::cin >> N >> line;

    xs.resize(N);
    os.resize(N);

    int cxs = 0;
    int cos = 0;
    int i = 0;
    while (i < N)
    {
        char c = line[i];
        if (c == 'X') ++cxs;
        if (c == 'O') ++cos;
        xs[i] = cxs;
        os[i] = cos;
        ++i;
    }

    int result = 0;

    int tileSide = 3;
    int tileSize = tileSide * tileSide;
    while (tileSize <= N)
    {
        int j = 0;
        while (j + tileSize <= N)
        {
            if (is_tile(j, j + tileSize - 1))
            {
                ++result;
            }
            ++j;
            //advance_j(j);
        }

        ++tileSide;
        tileSize = tileSide * tileSide;
    }

    std::cout << result;

//    std::cout << is_square(9) << '\n';
//    std::cout << is_square(10) << '\n';
//    std::cout << is_square(16) << '\n';
//    std::cout << is_square(17) << '\n';
//    std::cout << is_square(25) << '\n';
//    std::cout << is_square(100) << '\n';

//    std::cout << xs_in(0, N - 1) << '\n';
//    std::cout << os_in(0, N - 1) << '\n';
//
//    std::cout << xs_in(0, 2) << '\n';
//    std::cout << xs_in(0, 3) << '\n';
//
//    std::cout << xs_in(0, 4) << '\n';
//    std::cout << os_in(0, 4) << '\n';
//
//    std::cout << os_in(3, N - 1) << '\n';

    return 0;
}