#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int acum[108000];
Int dp[108000];
vector<Int> pos[3];
string s;
vector<Int> rep;
int main(){
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'a')acum[i+1] = acum[i] + 1;
    else acum[i+1] = acum[i] + 2;
    acum[i+1]%=3;
    pos[acum[i+1]].push_back(i);
    if(i && s[i] == s[i-1])rep.push_back(i);
  }
  if(rep.empty()){
    cout << 1 << endl;
    return 0;
  }
  dp[0] = 1;
  for(int i = 0;i < s.size();i++){
    dp[i+1] = (dp[i+1] + dp[i]) % MOD;
    auto nxtrep = upper_bound(rep.begin(), rep.end(), i);
    if(nxtrep == rep.end())continue;
    int k = *nxtrep;
    for(int j = 1;j <= 2;j++){
      if(s[i] == 'a' && j == 1)continue;
      if(s[i] == 'b' && j == 2)continue;
      int to = (acum[i] + j) % 3;
      auto nxtpos = lower_bound(pos[to].begin(), pos[to].end(), k);
      if(nxtpos == pos[to].end())continue;
      dp[*nxtpos+1] = (dp[*nxtpos+1] + dp[i]) % MOD;
    }
  }
  Int res = 0;
  for(int i:pos[acum[s.size()]]){
    res = (res + dp[i+1]) %MOD;
  }
  cout << res << endl;
  return 0;
}