#include <bits/stdc++.h>
int main() {
  int i, j, count = 0, before_count = 0, totyu_count, final_count;
  char s[100000], tmp[100000];
  scanf("%s", s);
  for (i = 0; s[i] != '\0'; i++) {
    before_count++;
  }
  do {
    count = 0;
    totyu_count = 0;
    for (i = 0; s[i] != '\0'; i++) {
      if ((s[i] == '0' && s[i + 1] == '1') ||
          (s[i] == '1' && s[i + 1] == '0')) {
        s[i] = '2';
        s[i + 1] = '2';
        count++;
      }
      totyu_count++;
    }
    for (j = 0; j < totyu_count; j++) {
      tmp[j] = '\0';
    }
    final_count = 0;
    for (i = 0, j = 0; s[i] != '\0'; i++) {
      if (s[i] != '2') {
        tmp[j] = s[i];
        j++;
        final_count++;
      }
    }
    for (j = 0; s[j] != '\0'; j++) {
      s[j] = '\0';
    }
    for (j = 0, i = 0; j < final_count; j++) {
      s[i] = tmp[j];
      i++;
    }
  } while (count != 0);
  for (i = 0; s[i] != '\0'; i++) {
  }
  printf("%d\n", before_count - i);
  return 0;
}
