#include <bits/stdc++.h>
using namespace std;
int check_delete(int idx_left, int idx_right, char *cubes, int n, int num_del) {
  if (idx_left == 0) return num_del;
  if (idx_right == n - 1) return num_del;
  if (cubes[idx_left - 1] == cubes[idx_right + 1]) return num_del;
  return check_delete(idx_left - 1, idx_right + 1, cubes, n, num_del + 2);
}
int main() {
  char cubes[100000];
  scanf("%s", cubes);
  int pre_n = strlen(cubes);
  int n = pre_n;
  while (true) {
    bool isnewdelete = false;
    int idx_right;
    for (idx_right = 1; idx_right < n; idx_right++) {
      if (cubes[idx_right] == cubes[idx_right - 1]) continue;
      isnewdelete = true;
      break;
    }
    if (!isnewdelete) break;
    int num_del = check_delete(idx_right - 1, idx_right, cubes, n, 2);
    idx_right = idx_right + num_del / 2;
    for (int i = idx_right; i < n; i++) {
      cubes[i - num_del] = cubes[i];
    }
    n -= num_del;
  }
  printf("%d", pre_n - n);
  return 0;
}
