#include <bits/stdc++.h>
using namespace std;
long long day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long dx[] = {0, 1, 0, -1};
long long dy[] = {1, 0, -1, 0};
struct edge {
  long long to, cost;
};
bool isupper(char c) {
  if ('A' <= c && c <= 'Z') return 1;
  return 0;
}
bool islower(char c) {
  if ('a' <= c && c <= 'z') return 1;
  return 0;
}
bool isPrime(long long x) {
  if (x == 1) return 0;
  if (x == 2) return 1;
  if (x % 2 == 0) return 0;
  for (long long i = 3; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
bool iskaibun(string s) {
  for (long long i = 0; i < s.size() / 2; i++)
    if (s[i] != s[s.size() - i - 1]) return 0;
  return 1;
}
bool isnumber(char c) { return ('0' <= c && c <= '9'); }
bool isalpha(char c) { return (isupper(c) && islower(c)); }
void print(vector<long long> v) {
  for (long long i = (long long)0; i < (long long)v.size(); i++) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}
signed main() {
  string s;
  cin >> s;
  s += "9";
  vector<long long> v(s.size(), 0);
  for (long long i = (long long)0; i < (long long)s.size(); i++) {
    if (v[i] == -1) continue;
    if (i < s.size() - 1) {
      if (s[i] != s[i + 1]) {
        v[i] = v[i + 1] = -1;
        long long diff = 1;
        while (i - diff >= 0 && i + diff + 1 < s.size()) {
          if (s[i - diff] != s[i + diff + 1] && v[i - diff] != -1 &&
              v[i + diff + 1] != -1) {
            v[i - diff] = v[diff + i + 1] = -1;
            diff++;
            continue;
          }
          break;
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = (long long)0; i < (long long)s.size(); i++) {
    ans += -v[i];
  }
  cout << ans << endl;
}
