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;
const long long N = 1e18 + 7;
const int M = 1e5 + 7;
long long MOD = 1e9 + 7;
vector<int> a, b;
int ans, frb[M];
string s;
int main() {
  cin >> s;
  int j = -1;
  for (int i = 0; s[i]; ++i) {
    if (s[i] == 'a') ++ans;
    if (s[i] != 'b' && s[i - 1] == 'b') b.push_back(i - 1);
    if (s[i] != 'b') j = i;
    if (s[i] == 'b' && i == 0)
      frb[i] = 1;
    else if (s[i] == 'b')
      frb[i] = frb[i - 1] + 1;
    else
      frb[i] = frb[i - 1];
  }
  for (int i = 0; s[i]; ++i) {
    if (s[i] == 'a') {
      int it = upper_bound(b.begin(), b.end(), i) - b.begin();
      if (it != b.size()) {
        ans += ((j - b[it]) - (frb[j] - frb[b[it]])) % MOD;
      }
    }
  }
  cout << ans;
  return 0;
}
