#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b) {
  a %= 1000000007;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = s.length();
  int a[n];
  for (long long i = 0; i < n; i++) a[i] = s[i] - 48;
  int ans = 0, lst = 0;
  vector<int> v;
  for (long long i = 0; i < n; i++) {
    if (a[i] % 3 == 0) {
      v.clear();
      ans++;
    } else {
      v.push_back(a[i]);
      int cs = 0;
      for (int j = v.size() - 1; j >= 0; j--) {
        cs += v[j];
        if (cs % 3 == 0) {
          ans++;
          v.clear();
          break;
        }
      }
    }
  }
  cout << ans;
}
