#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, n, test_case, cnt = 0;
  test_case = 1;
  string str;
  while (test_case--) {
    cin >> str;
    int arr[str.length() + 1];
    int dp[str.length() + 1];
    memset(arr, 0, sizeof arr);
    memset(dp, 0, sizeof dp);
    for (i = 1; i <= str.length(); i++) {
      arr[i] = arr[i - 1] + str[i - 1] - '0';
      arr[i] %= 3;
    }
    int flag[3] = {1, 0, 0};
    for (i = 1; i <= str.length(); i++) {
      dp[i] = dp[i - 1];
      if (flag[arr[i]]) dp[i] = max(dp[i - 1], dp[flag[arr[i]]] + 1);
      flag[arr[i]] = i;
    }
    cout << dp[str.length()];
  }
  return 0;
}
