#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
using namespace std;
int main() {
  string str;
  cin >> str;
  int n = str.length();
  int rem[3];
  int ans[n + 1];
  memset(rem, (-1), sizeof(rem));
  rem[0] = 0;
  ans[0] = 0;
  int r = 0;
  for (int i = 1; i <= n; ++i) {
    r = (r + str[i - 1] - '0') % 3;
    ans[i] = ans[i - 1];
    if (rem[r] != -1) {
      ans[i] = max(ans[i], ans[rem[r]] + 1);
    }
    rem[r] = i;
  }
  cout << ans[n];
  return 0;
}
