aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<int> v;
  int count = 0;
  int p = 0;
  for (int k = 0; k < s.length(); k++) {
    if (s.at(k) == 'a') {
      count++;
      p = 1;
    } else {
      if (p == 1) {
        v.push_back(count);
        count = 0;
        p = 0;
      }
    }
  }
  v.push_back(count);
  int value = 0;
  for (int i = 0; i < v.size() - 1; i++) {
    for (int k = i + 1; k < v.size(); k++) {
      value += v[i] * v[k];
    }
  }
  int q = v.size();
  int z = (value + q);
  cout << z << endl;
}
