#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  string s;
  cin >> s;
  vector<int> sol(s.size());
  for (int i = 0; i < s.size(); i++) {
    int val = s[i] - '0';
    sol[i] = val % 3;
  }
  int ans = 0;
  int sum = 0;
  int sumMod = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += sol[i];
    sumMod++;
    if (sol[i] % 3 == 0 || sum % 3 == 0 || sumMod == 3) {
      sumMod = 0;
      ans++;
      sum = 0;
    }
  }
  cout << ans;
}
