#include <bits/stdc++.h>
char a[200010];
int main() {
  int s;
  scanf("%s", a);
  s = strlen(a);
  int ans = 0;
  int cnt[3] = {0};
  for (int k = 0; k < s; k++) {
    int x = a[k] - '0';
    if (x % 3 == 0) {
      ans++;
      cnt[1] = cnt[2] = 0;
      continue;
    }
    cnt[x % 3]++;
    if (cnt[1] >= 1 && cnt[2] >= 1) {
      ans++;
      cnt[1] = cnt[2] = 0;
      continue;
    }
    if (cnt[1] >= 3 || cnt[2] >= 3) {
      ans++;
      cnt[1] = cnt[2] = 0;
      continue;
    }
  }
  printf("%d", ans);
}
