#include <bits/stdc++.h>
using namespace std;
map<long long, long long> m;
signed main() {
  string s;
  cin >> s;
  long long l = s.length();
  long long dp[l];
  memset(dp, 0, sizeof(dp));
  if (s[0] % 3 == 0) dp[0] = 1;
  for (long long i = 1; i < l; i++) {
    long long sum = 0;
    for (long long j = i; j >= 0; j--) {
      sum += (s[j] - '0');
      if (sum % 3 == 0) {
        if (j > 0)
          dp[i] = max(dp[i], 1 + dp[j - 1]);
        else {
          dp[i] = max(dp[i], (long long)1);
        }
        break;
      }
    }
    dp[i] = max(dp[i], dp[i - 1]);
  }
  cout << dp[l - 1] << endl;
}
