#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define enter putchar('\n')
#define space putchar(' ')
#define fi first
#define se second
//#define ivorysi
#define pii pair<int,int>
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}

template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
char s[100005];
int nxt[100005][3],sum[100005],dp[100005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    scanf("%s",s + 1);
    N = strlen(s + 1);
    bool flag = 0;
    for(int i = 2 ; i <= N ; ++i) {
        if(s[i] == s[i - 1]) {flag = 1;break;}
    }
    if(!flag) {puts("1");return;}
    for(int i = 1 ; i <= N ; ++i) {
        sum[i] = (sum[i - 1] + (s[i] - '0')) % 3;
    }
    for(int i = 0 ; i < 3 ; ++i) nxt[N + 1][i] = N + 1;
    for(int i = N ; i >= 1 ; --i) {
        for(int j = 0 ; j < 3 ; ++j) nxt[i][j] = nxt[i + 1][j];
        nxt[i][sum[i]] = i;
    }
    dp[0] = 1;
    for(int i = 0 ; i <= N ; ++i) {
        for(int j = 1 ; j <= 2 ; ++j) {
            update(dp[nxt[i + 1][(sum[i] + j) % 3]],dp[i]);
        }
    }
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(sum[i] == sum[N]) update(ans,dp[i]);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}
