#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int64_t n = s.size();
  vector<int64_t> freq(3);
  int64_t cnt = 0;
  int64_t cur = 0;
  for (int64_t i = 0; i < n; i++) {
    int64_t x = s[i] - '0';
    x += cur;
    int64_t rem = x % 3;
    if (freq[rem] or rem == 0) {
      cnt++;
      for (int64_t j = 0; j < 3; j++) freq[j] = 0;
      cur = 0;
    } else {
      freq[rem]++;
      cur = x;
    }
  }
  cout << cnt << "\n";
  return 0;
}
