#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t, x, y, i, j, m, k, n;
  string s;
  cin >> s;
  n = s.length();
  vector<int> dp(3, -1);
  vector<int> z(n + 1);
  dp[0] = 0;
  int sum = 0;
  z[0] = 0;
  for (i = 1; i <= n; i++) {
    sum = (sum + s[i - 1] - '0') % 3;
    z[i] = z[i - 1];
    if (dp[sum] != -1) z[i] = max(z[i], 1 + z[dp[sum]]);
    dp[sum] = i;
  }
  cout << z[n] << "\n";
  return 0;
}
