#include <bits/stdc++.h>
using namespace std;
string s;
int dp[200100][3];
int calc(int idx, int sum) {
  if (idx == s.size()) return sum % 3 == 0;
  int &ret = dp[idx][sum % 3];
  if (ret != -1) return ret;
  ret = 0;
  if (sum % 3 == 0)
    ret = max(ret, int(idx > 0) + calc(idx + 1, s[idx] - '0'));
  else
    ret = max({ret, calc(idx + 1, s[idx] - '0'),
               calc(idx + 1, sum + (s[idx] - '0'))});
  return ret;
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> s;
  cout << calc(0, 0) << endl;
  return 0;
}
