#include <bits/stdc++.h>
using namespace std;
char a[200010];
int main() {
  while (~scanf("%s", a)) {
    int l = strlen(a);
    int i, t, s = 0, sum = 0, k = 0;
    for (i = 0; i < l; i++) {
      t = (a[i] - '0') % 3;
      s += a[i] - '0';
      k++;
      if (t == 0 || s % 3 == 0 || k == 3) {
        sum++;
        k = 0;
        s = 0;
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
