#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int dp[N][5];
string s;
int solve(int idx, int rem) {
  if (idx == s.size()) return 0;
  int &ans = dp[idx][rem];
  if (ans != -1) return dp[idx][rem];
  int val = (s[idx] - '0') % 3;
  if ((val + rem) % 3 == 0) {
    ans = solve(idx + 1, 0) + 1;
  } else
    ans = max({ans, solve(idx + 1, (rem + val) % 3), solve(idx + 1, 0)});
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  cin >> s;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0);
}
