#include <bits/stdc++.h>
using namespace std;
int dp[200005][3];
string s;
int n;
int solve(int pos, int mod) {
  if (pos == n) {
    return 0;
  }
  if (dp[pos][mod] != -1) return dp[pos][mod];
  int num = s[pos] - '0';
  int ans = -1;
  if (num == 0) {
    ans = max(ans, solve(pos + 1, 0) + 1);
  } else if ((mod + num) % 3 == 0) {
    ans = max(ans, solve(pos + 1, 0) + 1);
  } else {
    ans = max(solve(pos + 1, 0), solve(pos + 1, (mod + num) % 3));
  }
  return dp[pos][mod] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  n = s.size();
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0) << '\n';
  return 0;
}
