#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x < y ? x : y; }
void _(long long& a, long long b) {
  a = (a % 1000000007 + b % 1000000007) % 1000000007;
  a = (a + 1000000007) % 1000000007;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long n = s.size();
  long long a[n + 1];
  a[0] = 0;
  for (int i = 0; i < n; ++i) {
    a[i + 1] = (s[i] - '0') % 3;
  }
  long long dp[n + 1];
  memset(dp, 0, sizeof(dp));
  if (a[1] == 0) dp[1] = 1;
  for (long long i = 2; i <= n; i++) {
    if (a[i] == 0)
      dp[i] = 1 + dp[i - 1];
    else if (a[i] == 1) {
      if (a[i - 1] == 2)
        dp[i] = max(dp[i], 1 + dp[i - 2]);
      else if (a[i - 1] == 0 and a[i - 2] == 2 and i - 3 >= 0)
        dp[i] = max(dp[i], dp[i - 3] + 1);
      else if (a[i - 1] == 1 and a[i - 2] == 1 and i - 3 >= 0)
        dp[i] = max(dp[i], dp[i - 3] + 1);
    } else {
      if (a[i - 1] == 1)
        dp[i] = max(dp[i], 1 + dp[i - 2]);
      else if (a[i - 1] == 0 and a[i - 2] == 1 and i - 3 >= 0)
        dp[i] = max(dp[i], dp[i - 3] + 1);
      else if (a[i - 1] == 2 and a[i - 2] == 2 and i - 3 >= 0)
        dp[i] = max(dp[i], dp[i - 3] + 1);
    }
    dp[i] = max(dp[i], dp[i - 1]);
  }
  cout << dp[n];
}
