#include <bits/stdc++.h>
using namespace std;
int a[200010], dp[200010];
char s[200010];
int main() {
  int len, i, t, j;
  scanf("%s", s);
  len = strlen(s);
  for (i = 0; i < len; i++) a[i + 1] = (s[i] - '0') % 3;
  if (a[1] == 0) dp[1]++;
  for (i = 2; i <= len; i++) {
    dp[i] = dp[i - 1];
    if (a[i] == 0) {
      dp[i] = dp[i - 1] + 1;
    } else if (a[i] == 1) {
      t = 0;
      for (j = i - 1; j > 0; j--) {
        t += a[j];
        if (t % 3 == 2) break;
      }
      if (j > 0) dp[i] = max(dp[j - 1] + 1, dp[i - 1]);
    } else {
      t = 0;
      for (j = i - 1; j > 0; j--) {
        t += a[j];
        if (t % 3 == 1) break;
      }
      if (j > 0) dp[i] = max(dp[j - 1] + 1, dp[i - 1]);
    }
  }
  printf("%d", dp[len]);
  return 0;
}
