#include <bits/stdc++.h>
using namespace std;
string s;
const int maxn = 2e5 + 10;
vector<int> f(3), dp(maxn);
void get_input() { cin >> s; }
void solve() {
  f[0] = 0, f[1] = -1, f[2] = -1;
  int n = s.size(), kom = 0;
  string lom = "";
  for (int i = 1; i <= n; i++) {
    lom = s[i - 1];
    kom = (kom + stoi(lom)) % 3;
    dp[i] = dp[i - 1];
    if (f[kom] != -1) {
      dp[i] = max(dp[i], dp[f[kom]] + 1);
    }
    f[kom] = i;
  }
}
void output() { cout << dp[s.size()]; }
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tc = 1;
  while (tc--) {
    get_input(), solve(), output();
  }
  return 0;
}
