#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int dp[maxn];
int main() {
  string s;
  while (cin >> s) {
    int n = s.size();
    int sum;
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < n; i++) {
      sum = 0;
      if (i)
        ;
      dp[i] = dp[i - 1];
      for (int j = i; j >= 0; j--) {
        sum += s[j];
        if (sum % 3 == 0) {
          if (j == 0)
            dp[i] = max(1, dp[i]);
          else
            dp[i] = max(dp[j - 1] + 1, dp[i]);
          break;
        }
      }
    }
    cout << dp[n - 1] << endl;
  }
}
