#include #include #include #include #include #include using namespace std; using ll = long long; #define umap unordered_map #define uset unordered_set #define int ll namespace std { template struct hash> { size_t operator()(const pair &a) const { return std::hash()(a.first) ^ (std::hash()(a.second) << 10); } }; } signed main() { int cunt = 0; cin >> cunt; vector sumx(cunt + 1, 0); vector 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; ll last_cx = 0; ll last_cy = 0; for (int left = 0; left < cunt; ++left) { for (int right = cunt; right >= left; right--) { int y_count = sumy[right] - sumy[left]; int x_count = sumx[right] - sumx[left]; if(last_cx == x_count || last_cy == y_count) break; last_cy = y_count; last_cx = x_count; 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; }