#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  int arr[3];
  memset(arr, -1, sizeof(arr));
  arr[0] = 0;
  int dp[n + 1];
  for (int i = 0; i <= n; i++) dp[i] = 0;
  int pre = 0;
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    pre = (pre + s[i - 1] - '0') % 3;
    if (arr[pre] != -1) {
      dp[i] = max(dp[i], dp[arr[pre]] + 1);
    }
    arr[pre] = i;
  }
  cout << dp[n];
  return 0;
}
