#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 7;
int dp[maxn], cnt;
string n;
int F(int c) {
  int ans = n[c] - '0';
  return ans;
}
int M3(int x) {
  int sum = F(x), ans, y = x;
  while (x && sum % 3) x--, sum += F(x);
  if (sum % 3)
    return -2;
  else
    return x - 1;
}
void DP() {
  if (F(0) % 3 == 0) dp[0] = 1;
  ;
  for (int i = 1; i < n.size(); i++) {
    cnt = M3(i), dp[i] = dp[i - 1];
    cnt + 1 ? dp[i] = max(1 + dp[cnt], dp[i]) : dp[i] = max(dp[i], 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n, DP(), cout << dp[n.size() - 1];
}
