#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long n, dp[200000], ans = 0, a[3];
string second;
int32_t main() {
  cin >> second;
  n = second.size();
  a[0] = 0;
  a[1] = 0;
  a[2] = 0;
  for (long long i = 0; i < n; i++) {
    if (i != 0) {
      dp[i] = (dp[i - 1] + (second[i] - '0')) % 3;
    } else {
      dp[i] = (second[i] - '0') % 3;
    }
    if (dp[i] % 3 == 0 || (second[i] - '0') % 3 == 0 || a[dp[i] % 3] != 0) {
      ans++;
      dp[i] = 0;
      a[0] = 0;
      a[1] = 0;
      a[2] = 0;
    } else {
      a[dp[i] % 3] = 1;
    }
  }
  cout << ans;
  return 0;
}
