#include <bits/stdc++.h>
using namespace std;
int val(char ch) { return (ch - '0') % 3; }
int main() {
  string s;
  cin >> s;
  int a[s.size()];
  for (int i = 0; i < s.size(); i++) {
    a[i] = val(s[i]);
  }
  int p = 0, c = 0;
  map<int, int> m;
  for (int i = 0; i < s.size(); i++) {
    if (a[i] != 0) {
      p += a[i];
      if (p % 3 == 0 || m[(p % 3)] > 0) {
        p = 0;
        m.clear();
        c++;
      } else {
        m[p % 3]++;
      }
    } else {
      m.clear();
      p = 0;
      c++;
    }
  }
  cout << c;
}
