#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long a, long long b, long long m) {
  if (b == 0) return 1 % m;
  long long x = bigmod(a, b / 2, m);
  x = (x % m * x % m) % m;
  if (b % 2) x = (x % m * a % m) % m;
  return x;
}
int d[200006][20];
string s;
int f(int i, int t) {
  if (i == s.size()) return 0;
  if (d[i][t] != -1) return d[i][t];
  return d[i][t] =
             max(((t + s[i] - '0') % 3 == 0) + f(i + 1, (t + s[i] - '0') % 3),
                 f(i + 1, 0));
}
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    for (int j = 0; j < 4; j++) d[i][j] = -1;
  cout << f(0, 0) << endl;
}
