#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int count = 0;
  cin >> s;
  int sizes = s.size();
  for (int j = 0; j < 100; j++) {
    for (int i = 0; i < sizes; i++) {
      if (s[i] + s[i + 1] == 97) {
        count = count + 2;
        s.erase(s.begin() + i);
        s.erase(s.begin() + i);
        i = i - 1;
        sizes = s.size();
      } else {
      }
      if (sizes == 0) {
        break;
      }
      bool wa = true;
      for (int i = 0; i < sizes; i++) {
        if (s[0] == s[i]) {
        } else {
          wa = false;
        }
      }
      if (wa == true) {
        break;
      }
    }
  }
  cout << count << endl;
}
