#include using namespace std; int main() { int n, i, j; string s; cin >> n; cin >> s; int maxA = (int)sqrt(n), in, out, tot = 0; char C = 'O'; for (i = 3; i <= maxA; i++) { int in = out = 0, m = i * i; for (j = 0; j < m; j++) { if (s[j] == C) in++; else out++; } for (j = 0; j < n - m; j++) { if (in == (i - 2) * (i - 2) && in + out == m) tot++; if (out == (i-2)*(i-2) && in + out == m) tot++; if (s[j] == C) in--; else out--; if (s[j + m] == C) in++; else out++; } if (in == (i - 2) * (i - 2) && in + out == m) tot++; if (out == (i-2)*(i-2) && in + out == m) tot++; } cout << tot << endl; }