#include <bits/stdc++.h>
using namespace std;
int dp[200005] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if ((s[i] - '0') % 3 == 0) {
      ans++;
      dp[i] = 1;
    }
  }
  int cnt = 0, res;
  vector<long long int> v;
  for (int i = 0; i < n; i++) {
    if (dp[i] == 1) {
      cnt = 0;
      v.clear();
      continue;
    }
    v.push_back(s[i] - '0');
    cnt += s[i] - '0';
    if (cnt % 3 == 0) {
      cnt = 0;
      dp[i] = 1;
      v.clear();
      ans++;
    } else if (v.size() >= 3) {
      res = cnt;
      for (int j = 0; j < v.size() - 2; j++) {
        res -= v[j];
        if (res % 3 == 0) {
          ans++;
          cnt = 0;
          dp[i] = 1;
          v.clear();
          break;
        }
      }
    }
  }
  cout << ans;
}
