#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
const long long N = 1e6 + 10;
void go() {
  string s;
  cin >> s;
  long long m[3] = {0};
  long long cnt = 0;
  for (long long i = 0; i < (long long)s.size(); i++) {
    long long x = s[i] - '0';
    x = x % 3;
    if (m[3 - x] || x == 0) {
      cnt++;
      memset(m, 0, sizeof(m));
    } else {
      long long temp[3] = {0};
      temp[x] = 1;
      for (long long i = 0; i < 3; i++) {
        if (m[i]) {
          temp[(i + x) % 3] = 1;
          m[i] = 0;
        }
      }
      for (long long i = 0; i < 3; i++) m[i] = temp[i];
    }
  }
  cout << cnt;
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long t = 1;
  cout << fixed << setprecision(12);
  while (t--) {
    go();
  }
}
