#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  int n = s.length();
  int r = 0;
  vector<int> f(3, -1);
  f[0] = 0;
  vector<int> z(n + 1);
  for (int i = 1; i < (n + 1); ++i) {
    r = (r + s[i - 1] - '0') % 3;
    z[i] = z[i - 1];
    if (f[r] != -1) z[i] = max(z[i], z[f[r]] + 1);
    f[r] = i;
  }
  cout << z[n] << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  for (int z = 0; z < t; z++) {
    solve();
  }
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  return 0;
}
