#include <bits/stdc++.h>
using namespace std;
char z[1000005];
long long k, len, ind;
vector<long long> vis, c;
string str;
void pf(long long, long long);
string lcs2(string, string, long long, long long);
long long bfs(vector<long long>[], long long, long long);
void solve() {
  long long n, i, j, x, y1, y, l = 1, b, m = 0, c = 0, d = 0;
  string s;
  cin >> s;
  n = s.size();
  map<long long, long long> p;
  for (long long int i = 0; i < n; i++) {
    if (((long long)s[i] - 48) % 3 != 0) {
      d = d + (long long)s[i] - 48;
      if ((d % 3 == 0) || (p[d % 3] > 0)) {
        c++;
        d = 0;
        p.clear();
      } else {
        p[d % 3] = 1;
      }
    } else {
      c++;
      d = 0;
      p.clear();
    }
  }
  cout << c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
    cout << "\n";
  }
  return 0;
}
