#include <bits/stdc++.h>
using namespace std;
char s[200005], r[200005];
int dp[200005] = {0};
int main() {
  cin >> s;
  int n = strlen(s);
  int i;
  for (i = 0; i < n; i++) {
    r[i] = (int)(s[i] - '0') % 3;
  }
  if (r[0] == 0) dp[0] = 1;
  for (i = 1; i < n; i++) {
    if (r[i] == 0) {
      dp[i] = 1 + dp[i - 1];
    } else if (r[i] == 1) {
      if (r[i + 1] == 0) {
        dp[i] = dp[i - 1];
      } else if (r[i + 1] == 2) {
        dp[i] = dp[i - 1];
        i++;
        dp[i] = 1 + dp[i - 1];
      } else {
        if (r[i + 2] == 1) {
          dp[i] = dp[i + 1] = dp[i - 1];
          i += 2;
          dp[i] = 1 + dp[i - 1];
        } else {
          dp[i] = dp[i - 1];
          continue;
        }
      }
    } else if (r[i] == 2) {
      if (r[i + 1] == 0) {
        dp[i] = dp[i - 1];
      } else if (r[i + 1] == 1) {
        dp[i] = dp[i - 1];
        i++;
        dp[i] = 1 + dp[i - 1];
      } else {
        if (r[i + 2] == 2) {
          dp[i] = dp[i + 1] = dp[i - 1];
          i += 2;
          dp[i] = 1 + dp[i - 1];
        } else {
          dp[i] = dp[i - 1];
          continue;
        }
      }
    }
  }
  cout << dp[n - 1];
  return 0;
}
