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