#include <bits/stdc++.h>
using namespace std;
const int sz = 200005;
string s;
int crm[sz], like[sz];
int fn[] = {-1, -1, -1}, mem[sz];
int solve(int i) {
  if (i == s.size()) return 0;
  int &ret = mem[i];
  if (ret != -1) return ret;
  ret = solve(i + 1);
  if (like[i] != -1) ret = max(ret, solve(like[i]) + 1);
  return ret;
}
int main() {
  cin >> s;
  fn[0] = s.size();
  for (int i = 0; i <= s.size(); i++) mem[i] = -1;
  for (int i = s.size() - 1; i >= 0; i--) {
    crm[i] = (crm[i + 1] + (s[i] - '0')) % 3;
    like[i] = fn[crm[i]];
    fn[crm[i]] = i;
  }
  cout << solve(0) << endl;
  return 0;
}
