#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string cad;
  cin >> cad;
  vector<long long> vect;
  for (long long i = 0; i < cad.size(); i++) {
    long long val = (cad[i] - '0') % 3;
    vect.push_back(val);
  }
  map<long long, bool> mp;
  mp[0] = true;
  long long acum = 0;
  long long res = 0;
  for (auto x : vect) {
    acum += x;
    acum %= 3;
    if (mp[acum]) {
      res++;
      mp.clear();
      mp[0] = true;
      acum = 0;
    } else {
      mp[acum] = true;
    }
  }
  cout << res << '\n';
  return 0;
}
