#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <valarray>

using namespace std;

using ll = long long;
#define umap unordered_map
#define uset unordered_set
#define int ll

namespace std {
    template<typename T, typename U>
    struct hash<pair<T, U>> {
        size_t operator()(const pair<T, U> &a) const {
            return std::hash<T>()(a.first) ^ (std::hash<U>()(a.second) << 10);
        }
    };
}


ll pascal(ll n, ll k) {
    static umap<pair<ll, ll>, ll> triangle;
    pair<ll, ll> key = {n, k};

    if (n == 0 || k == 0 || k == n) return 1;

    if (triangle.count(key)) {
        return triangle[key];
    }

    ll a = pascal(n - 1, k - 1);
    ll b = pascal(n - 1, k);
    ll newVal = a + b;

    if (a < 0 || b < 0 || a + b < 0) {
        newVal = -1;
    }

    triangle[key] = newVal;
    return newVal;
}

signed main() {
    int cunt = 0;
    cin >> cunt;
    vector<ll> sumx(cunt + 1, 0);
    vector<ll> sumy(cunt + 1, 0);
    char current;
    string acum;
    for (int i = 0; i < cunt; ++i) {
        cin >> current;
        sumx[i + 1] = sumx[i] + (current == 'X');
        sumy[i + 1] = sumy[i] + (current == 'O');
        acum += current;
//        cout << current;
    }
    int possible = 0;

    for (int left = 0; left < cunt; ++left) {
        for (int right = cunt; right >= left; right--) {
            int x_count = sumx[right] - sumx[left];
            int y_count = sumy[right] - sumy[left];

            if (x_count > y_count) swap(x_count, y_count);
            if (x_count < 1 || y_count < 8) {
                break;
            }

            auto isValid = [](ll x, ll y) {
                ll s = sqrt((double) x);
                return s * s == x && (s + 1) * 4 == y;
            };

            if (isValid(x_count, y_count)) possible++;
            if (isValid(y_count, x_count)) possible++;

//            for (int i = left; i < right; ++i) {
//                cout << acum[i];
//            }
//            cout << ": " << x_count << ":" << y_count << endl;
        }
    }
    cout << possible << endl;
    return 0;
}