#include <bits/stdc++.h>
using namespace std;
int md = 1000000009;
const int IN = 2 * 1e5 + 15;
int ti(char c) { return (c - '0') % 3; }
int main() {
  long long int a, b, n, k, ans = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.size();) {
    if (ti(s[i]) == 0) {
      ans++;
      i++;
    } else if (ti(s[i]) == 1) {
      if (i + 1 < s.size() && (ti(s[i + 1]) == 2 || ti(s[i + 1]) == 0)) {
        ans++;
        i += 2;
      } else if (i + 2 < s.size() && (ti(s[i + 2]) == 1)) {
        ans++;
        i += 3;
      } else {
        i++;
      }
    } else {
      if (i + 1 < s.size() && (ti(s[i + 1]) == 1 || ti(s[i + 1]) == 0)) {
        ans++;
        i += 2;
      } else if (i + 2 < s.size() && (ti(s[i + 2]) == 2)) {
        ans++;
        i += 3;
      } else {
        i++;
      }
    }
  }
  cout << ans;
  return 0;
}
