#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
const int N = 200020;
int dp[N][3];
int main() {
  string s;
  cin >> s;
  for (int(i) = 0; (i) < (int)(N); ++(i))
    for (int(j) = 0; (j) < (int)(3); ++(j)) dp[i][j] = -19191919;
  dp[0][0] = 0;
  int n = s.size();
  for (int(i) = 0; (i) < (int)(n); ++(i))
    for (int(j) = 0; (j) < (int)(3); ++(j)) {
      int nj = (j + s[i] - '0') % 3;
      if (nj == 0) {
        dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + 1);
      } else {
        dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j]);
        dp[i + 1][0] = max(dp[i + 1][0], dp[i][j]);
      }
    }
  int ans = 0;
  for (int(i) = 0; (i) < (int)(3); ++(i)) ans = max(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}
