#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e10 + 10;
const long long N = 2e5 + 10;
long long a[N];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long n = s.size();
  for (long long i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
    a[i] %= 3;
  }
  long long res = 0;
  for (long long i = 0; i < n; ++i) {
    if (a[i] == 0) {
      ++res;
    } else if (a[i] == 1) {
      if (i + 1 < n && a[i + 1] == 2) {
        ++res;
        i += 1;
      } else if (i + 2 < n && a[i + 1] == 1 && a[i + 1] == 1) {
        ++res;
        i += 2;
      }
    } else if (a[i] == 2) {
      if (i + 1 < n && a[i + 1] == 1) {
        ++res;
        i += 1;
      } else if (i + 2 < n && a[i + 1] == 2 && a[i + 1] == 2) {
        ++res;
        i += 2;
      }
    }
  }
  cout << res << "\n";
  return 0;
}
