#include <bits/stdc++.h>
inline long long read() {
  long long x = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || '9' < c; c = getchar())
    if (c == '-') f = -1;
  for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
inline void write(long long x) {
  static char buf[20];
  int len = 0;
  if (x < 0) putchar('-'), x = -x;
  for (; x; x /= 10) buf[len++] = x % 10 + '0';
  if (!len)
    putchar('0');
  else
    while (len) putchar(buf[--len]);
}
inline void writesp(long long x) {
  write(x);
  putchar(' ');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
char s[200010];
int sum[200010], f[200010];
int n;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  sum[0] = 0;
  for (int i = 1; i <= n; i++)
    sum[i] = (sum[i - 1] + (s[i] == 'a' ? 1 : 2)) % 3;
  int flag = 1;
  for (int i = 1; i < n; i++)
    if (s[i] == s[i + 1]) flag = 1;
  if (flag) {
    puts("1");
    return 0;
  }
  f[0] = 1;
  int pos[3] = {-1, -1, -1};
  pos[0] = 0;
  for (int i = 1; i <= n; i++) {
    f[i] = (!sum[i]) && (i < n);
    if (~pos[(sum[i] + 1) % 3]) f[i] = (f[i] + f[pos[(sum[i] + 1) % 3]]);
    if (~pos[(sum[i] + 2) % 3]) f[i] = (f[i] + f[pos[(sum[i] + 2) % 3]]);
    pos[sum[i]] = i;
  }
  writeln(f[n]);
  return 0;
}
