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() {
  int i, j, k, n;
  string s;
  cin >> s;
  n = s.size();
  char ch = 'b';
  vector<int> v(n, 0), a;
  for (i = 0; i < n; i++) {
    if (i != 0) v[i] = v[i - 1];
    if (s[i] == 'a') {
      a.push_back(i);
      ch = 'a';
    } else if (s[i] == 'b') {
      if (ch == 'a') v[i]++;
      ch = 'b';
    }
  }
  long long res = a.size();
  n = a.size();
  for (i = 1; i < s.size(); i++) {
    for (j = 0; j <= n - i; j++) {
      int x = 0;
      while (j + x + i < n) {
        if (v[a[j + x + i]] - v[a[j]] >= i) res++;
        x++;
      }
    }
    res %= 1000000007;
  }
  cout << res;
}
