#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, n, c = 0, p = 0, al, bl, l = 0;
  string s;
  cin >> s;
  for (i = 0; i < s.length(); i++) {
    l++;
    c += (s[i] - '0');
    if (c % 3 == 0 || (s[i] - '0') % 3 == 0 || l >= 3) {
      p++;
      c = 0;
      l = 0;
    }
  }
  if (s[0] == '0') p--;
  cout << p;
}
