#include <bits/stdc++.h>
using namespace std;
int n, a[2 * 100011];
int dp[2 * 100011];
char str[2 * 100011];
int main() {
  gets(str);
  n = strlen(str);
  for (int i = 0; i < n; i++) a[i + 1] = (str[i] - '0') % 3;
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    if (a[i] == 0)
      dp[i]++;
    else if ((a[i - 1] + a[i]) % 3 == 0)
      dp[i] = max(dp[i], dp[i - 2] + 1);
    else if ((a[i - 2] + a[i - 1] + a[i]) % 3 == 0)
      dp[i] = max(dp[i], dp[i - 3] + 1);
  }
  cout << dp[n] << endl;
}
