#include <iostream>
#include <string>
using namespace std;

typedef long long ll;
const ll M = 1000000007;

int main(){
  string s;
  cin >> s;
  ll dp[3] = {};
    dp[1] = dp[2] = 1;
    ll ret[3] = {};
  int cnt = 100002;
  for(int i = 0 ; i < s.size() ; i ++){
    if(s[i] == 'a')cnt ++;
    else cnt --;
      ret[cnt%3] += dp[cnt%3];
    for(int k = 0 ; k < 3 ; k ++){
        if(k == cnt%3)continue;
      dp[k] += dp[cnt%3];
      if(dp[k] >= M)dp[k] -= M;
    }
      dp[cnt%3] = 0;
  }
  for(int i = 0 ; i+1 < s.size() ; i ++){
    if(s[i] == s[i+1]){
      cout << ret[cnt%3]%M << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}
