#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int i, temp, ans = 0, len, a[200005];
  string s;
  cin >> s;
  len = s.length();
  for (i = 0; i < len; i++) {
    temp = s[i] - 48;
    a[i] = temp % 3;
  }
  for (i = 0; i < len; i++) {
    if (a[i] == 0) {
      ans++;
      continue;
    }
    if (a[i] == 1) {
      if (i + 1 < len && a[i + 1] == 2) {
        ans++;
        i++;
        continue;
      }
      if (i + 2 < len && a[i + 1] == 1 && a[i + 2] == 1) {
        ans++;
        i += 2;
        continue;
      }
    }
    if (a[i] == 2) {
      if (i + 1 < len && a[i + 1] == 1) {
        ans++;
        i++;
        continue;
      }
      if (i + 2 < len && a[i + 1] == 2 && a[i + 2] == 2) {
        ans++;
        i += 2;
        continue;
      }
    }
  }
  cout << ans;
  return 0;
}
