#include <bits/stdc++.h>
using namespace std;
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
const long long int MOD = 1e9 + 7;
const long long int INF = 1e15;
const long long int MXN = 2e5 + 9;
long long int dp[MXN];
vector<long long int> hmm(3, -1);
void solve() {
  string s;
  cin >> s;
  long long int n = s.size();
  long long int rem = 0;
  hmm[0] = 0;
  for (long long int i = 1; i <= n; i++) {
    rem += (s[i - 1] - '0');
    rem %= 3;
    dp[i] = dp[i - 1];
    if (hmm[rem] != -1) dp[i] = max(dp[hmm[rem]] + 1, dp[i]);
    hmm[rem] = i;
  }
  cout << dp[n];
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  for (long long int i = 1; i <= t; i++) {
    solve();
  }
}
