#include <bits/stdc++.h>
using namespace std;
string s;
int dp[200002][4];
int solve(int i, int mod) {
  if (i == s.size()) {
    if (mod == 0)
      return 1;
    else
      return 0;
  }
  if (dp[i][mod] != -1) return dp[i][mod];
  int ans1, ans2;
  ans1 = ans2 = 0;
  if (mod == 0) {
    ans1 = solve(i + 1, (s[i] - '0') % 3) + 1;
  } else
    ans1 += solve(i + 1, (s[i] - '0') % 3);
  ans2 += solve(i + 1, (s[i] - '0' + mod) % 3);
  return dp[i][mod] = max(ans1, ans2);
}
int main() {
  cin >> s;
  memset(dp, -1, sizeof(dp));
  cout << solve(1, (s[0] - '0') % 3) << endl;
}
