#include <bits/stdc++.h>
using namespace std;
const long maxn = 1e6 + 1;
long val[maxn];
long f[maxn];
long vitri[4];
int main() {
  string s;
  cin >> s;
  long leng = s.length();
  for (long i = 0; i <= leng - 1; i++) val[i + 1] = long(s[i] - '0');
  for (long i = 1; i <= leng; i++) val[i] = val[i - 1] + val[i];
  for (long i = 1; i <= leng; i++) {
    long k = val[i] % 3;
    if (vitri[k] != 0)
      f[i] = f[vitri[k]] + 1;
    else if (k == 0)
      f[i] = f[i] + 1;
    vitri[k] = i;
    f[i] = max(f[i - 1], f[i]);
  }
  cout << f[leng];
}
