#include <bits/stdc++.h>
using namespace std;
const int mxm = 998244353;
const int mx = 2e5 + 1;
int dp[mx] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  dp[0] = 0;
  map<int, int> m;
  m[0] = 0;
  int n = s.size();
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    sum = sum + (s[i - 1] - '0') % 3;
    sum %= 3;
    if ((s[i - 1] - '0') % 3 == 0) {
      dp[i] = max(dp[i], dp[i - 1] + 1);
    }
    if (m.count(sum) == 1) {
      dp[i] = max(dp[i], dp[m[sum]] + 1);
    }
    dp[i] = max(dp[i], dp[i - 1]);
    m[sum] = i;
  }
  int best = 0;
  cout << dp[n];
}
