#include <bits/stdc++.h>
using namespace std;
int dp[200001];
int main() {
  string s;
  cin >> s;
  int n = s.length();
  int r = 0;
  vector<int> fin(3, -1);
  fin[0] = 0;
  for (int i = 1; i <= n; i++) {
    r = (r + (s[i - 1] - '0')) % 3;
    dp[i] = dp[i - 1];
    if (fin[r] != -1) {
      dp[i] = max(dp[i], dp[fin[r]] + 1);
    }
    fin[r] = i;
  }
  cout << dp[n] << endl;
  return 0;
}
