#include <bits/stdc++.h>
using namespace std;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
long long qp(long long x, long long y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  long long z = qp(x, y / 2);
  z = z * z % 1000000007;
  if (y & 1) z = z * x % 1000000007;
  return z;
}
string s;
int n, m, l[1000005], r[1000005], ans, i, j, k, t, vis[1000005], cnt;
int main() {
  cin >> s;
  for (i = 0; i < s.size(); i++) l[i] = i - 1, r[i] = i + 1;
  for (i = 0; i < s.size(); i = j + 1) {
    j = k = i;
    cnt = 0;
    int lst = s[i];
    while (r[j] < s.size() && (vis[r[j]] || lst != s[r[j]]))
      t = j, j = r[j], r[t] = r[r[t]], cnt += (!vis[j]),
      lst = vis[j] ? lst : s[j], vis[j] = 1;
    lst = s[i];
    while (l[k] >= 0 && (vis[l[k]] || lst != s[l[k]]))
      t = k, k = l[k], l[t] = l[l[t]], cnt += (!vis[k]),
      lst = vis[k] ? lst : s[k], vis[k] = 1;
    if (cnt) ans++, vis[i] = 1;
  }
  cout << ans;
  return 0;
}
