#include <bits/stdc++.h>
using namespace std;
static const int maxn = 1000000;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  int n = s.length();
  int i = 0;
  while (i < n) {
    short c = s[i] - '0';
    if (c % 3 == 0) {
      ans++;
      i++;
      continue;
    }
    if (i < n - 1 && (c + (s[i + 1] - '0')) % 3 == 0) {
      i = i + 2;
      ans++;
      continue;
    } else if (i < n - 2 && (s[i + 1] - '0') % 3 != 0 &&
               (c + (s[i + 1] - '0') + (s[i + 2] - '0')) % 3 == 0) {
      i = i + 3;
      ans++;
      continue;
    }
    i++;
  }
  cout << ans;
  return 0;
}
