#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int uk = 0;
  int niz[s.size()];
  for (int i = 0; i < s.size(); i++) {
    int a = s[i] - '0';
    niz[i] = a % 3;
  }
  int cnt = 0;
  while (cnt < s.size()) {
    if (niz[cnt] == 0) {
      uk++;
      cnt++;
    } else if (cnt + 1 < s.size() && (niz[cnt] * 10 + niz[cnt + 1]) % 3 == 0) {
      uk++;
      cnt += 2;
    } else if (cnt + 1 < s.size() && niz[cnt + 1] == 0) {
      uk++;
      cnt += 2;
    } else if (cnt + 2 < s.size()) {
      uk++;
      cnt += 3;
    } else
      cnt++;
  }
  cout << uk << endl;
  return 0;
}
