#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n, i, c = 0, sum = 0;
  string s;
  cin >> s;
  n = s.length();
  long long int a[n];
  for (i = 0; i < n; i++) {
    a[i] = (s[i] - '0') % 3;
  }
  long long int h[3] = {0};
  for (i = 0; i < n; i++) {
    h[a[i]]++;
    if (a[i] != 0) {
      if (h[1] == 1 && h[2] >= 1) {
        c++;
        h[1] = 0;
        h[2] = 0;
      } else if (h[2] == 1 && h[1] >= 1) {
        c++;
        h[1] = 0;
        h[2] = 0;
      } else if (h[2] == 3) {
        c++;
        h[2] = 0;
      } else if (h[1] == 3) {
        c++;
        h[1] = 0;
      }
    } else {
      h[1] = 0;
      h[2] = 0;
      c++;
    }
  }
  cout << c << endl;
}
