#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return a > b; }
int main() {
  string a;
  int n, c = 0, e, f;
  cin >> a;
  int m[3], h[200006];
  h[0] = 0;
  if ((a[0] - 48) % 3 == 0) {
    h[1] = 1;
  } else
    h[1] = 0;
  for (int i = 1; i <= a.size() - 1; i++) {
    e = 0;
    a[i] -= 48;
    n = i;
    if (a[i] % 3 == 0) {
      h[i + 1] = h[i] + 1;
    } else {
      c = a[i];
      f = 0;
      while (n--) {
        c = c + a[n];
        if (c % 3 == 0) {
          e = n;
          f = 1;
          break;
        }
      }
      h[i + 1] = max(h[i], h[e] + f);
    }
  }
  cout << h[a.size()] << endl;
  return 0;
}
