#include<bits/stdc++.h> #define SINGLE_INPUT #define ll long long #define ull unsigned long long #define N 500005 #define MOD 998244353 #define INF 0x3f3f3f3f usingnamespace std;
template<classt,classu> ostream& operator<<(ostream& os,const pair<t,u>& p) { return os<<'['<<p.first<<", "<<p.second<<']'; } template<classt> ostream& operator<<(ostream& os,const vector<t>& v) { os<<'['; int s = 1; for(auto e:v) { if (s) s = 0; else os << ", "; os << e; } return os<<']'; } template<classt,classu> ostream& operator<<(ostream& os,const map<t,u>& mp){ os<<'{'; int s = 1; for(auto [x,y]:mp) { if (s) s = 0; else os << ", "; os<<x<<": "<<y; } return os<<'}'; }
voidsol(){ string s; cin >> s; ll n = s.size(); ll ans = 0; vector<ll> k(n, -1); for (ll i=1; i<n; i++) { ll j; k[i] = k[i-1]; for (j=1; i-2*j>k[i]; j++) { if (s[i] == s[i-j] && s[i] == s[i-2*j]) { k[i] = i-2*j; break; } } ans += k[i]+1; } cout << ans << "\n"; }