#include <bits/stdc++.h>
using namespace std;
int main() {
  int b, ck = 0, dk = 5;
  string s;
  cin >> s;
  b = s.length();
  for (int i = 0; i < b; i++) {
    if (s[i] == 'a' && s[i + 1] == 'a') {
      ck++;
      dk = 0;
      s[i] = 'b';
      s.erase(i + 1, 1);
      if (s[i] != s[i + 1]) {
        ck = ck + s.length() - 1;
      }
    }
    if (s[i] == 'b' && s[i + 1] == 'b') {
      ck++;
      dk = 0;
      s[i] = 'a';
      s.erase(i + 1, 1);
      if (s[i] != s[i + 1]) {
        ck = ck + s.length() - 1;
      }
    }
    if (dk != 0) {
      dk = 1;
    }
  }
  if (dk == 1) {
    cout << dk << endl;
  } else
    cout << ck + 1 << endl;
  return 0;
}
