#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
long long arr[2004][2004];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    string s;
    cin >> s;
    long long n = s.size();
    long long ans = 0, ct = 0, len = 0;
    for (long long i = 0; i < n; ++i) {
      len++;
      if ((s[i] - '0') % 3 == 0) {
        ct++;
        ans = 0;
        len = 0;
        continue;
      }
      ans += (s[i] - '0');
      if (ans % 3 == 0 || len >= 3) {
        ct++;
        ans = 0;
        len = 0;
      }
    }
    cout << ct;
  }
  return 0;
}
