#include <bits/stdc++.h>
using namespace std;
void fastIO() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
template <typename T, typename U>
inline void mnze(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void mxze(T &x, U y) {
  if (x < y) x = y;
}
void _scan(int &x) { scanf("%d", &x); }
void _scan(long long &x) { scanf("%lld", &x); }
void _scan(double &x) { scanf("%lf", &x); }
void _scan(char &x) { scanf(" %c", &x); }
void _scan(char *x) { scanf("%s", x); }
void scan() {}
template <typename T, typename... U>
void scan(T &head, U &...tail) {
  _scan(head);
  scan(tail...);
}
template <typename T>
void _dbg(const char *sdbg, T h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename T, typename... U>
void _dbg(const char *sdbg, T h, U... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
int getbit(int msk, int i) { return (msk >> i) & 1; }
int dp[1000][10];
bool bad(int msk, int n) {
  int &ret = dp[msk][n];
  if (ret != -1) return ret;
  for (int i = 0; i < (int)n; i++) {
    for (int k = 1; i + 2 * k < (int)n; k++) {
      if (getbit(msk, i) == getbit(msk, i + k) &&
          getbit(msk, i) == getbit(msk, i + 2 * k))
        return (ret = 0);
    }
  }
  return (ret = 1);
}
const int MAXN = 3e5 + 5;
long long n;
char s[MAXN];
int main() {
  memset(dp, -1, sizeof(dp));
  scan(s);
  n = strlen(s);
  long long ans = n * (n - 1) / 2;
  for (int l = 0; l < (int)n; l++) {
    int msk = s[l] - '0';
    for (int r = l + 1; r < min((int)n, l + 9); r++) {
      msk = (msk << 1) + (s[r] - '0');
      ans -= bad(msk, r - l + 1);
    }
  }
  printf("%lld\n", ans);
}
