#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int count = 0;
  cin >> s;
  int sizes = s.size();
  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;
    } else {
      continue;
    }
  }
  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;
    } else {
      continue;
    }
  }
  cout << count << endl;
}
