#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  int t, n, i, j, ans = 0, sum = 0, c = 0;
  cin >> s;
  for (i = 0; i < s.length(); i++) {
    if (s[i] == '0') {
      sum = 0;
      c = 0;
      ans++;
      continue;
    }
    sum += s[i] - '0';
    c++;
    if (sum % 3 == 0) {
      ans++;
      sum = 0;
      c = 0;
    } else {
      if (s[i] % 3 == 0) {
        sum = 0;
        c = 0;
        ans++;
      } else {
        if (c == 3) {
          c = 0;
          sum = 0;
          ans++;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
