#include <bits/stdc++.h>
using namespace std;
void fileio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
}
string s;
int a[200005], res = 0;
int main() {
  fileio();
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) a[i] = (s[i] - 48) % 3;
  for (int i = 0; i < n; i++) {
    if (a[i] % 3 == 0)
      res++;
    else if ((a[i] + a[i + 1]) % 3 == 0 && a[i + 1] % 3 != 0 && i + 1 < n)
      res++, i++;
    else if ((a[i] + a[i + 1] + a[i + 2]) % 3 == 0 && a[i + 1] % 3 != 0 &&
             a[i + 2] % 3 != 0 && i + 2 < n)
      res++, i += 2;
  }
  cout << res;
  return 0;
}
