#include <bits/stdc++.h>
using namespace std;
deque<int> a;
int ans = 0;
void prot(char s) {
  if (a.size() == 1) {
    if (a.front() % 3 == 0) ans++;
    a.clear();
  }
  if (a.size() == 2 && (a.front() + a.back()) % 3 == 0) {
    a.clear();
    ans++;
  } else if (a.size() == 2) {
    a.clear();
  }
  if (a.size() == 3) {
    int a1, a2, a3;
    a3 = a.back();
    a.pop_back();
    a2 = a.back();
    a.pop_back();
    a1 = a.back();
    a.pop_back();
    ans++;
    if ((a1 + a2) % 3 == 0 && (s - '0') % 3 != 0) {
      a.push_back(a3);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  bool front = false;
  for (int i = 0; i < n; i++) {
    if ((s[i] - '0') % 3 != 0 && a.size() < 3)
      a.push_back((s[i] - '0') % 3);
    else {
      if ((s[i] - '0') % 3 == 0)
        ans++;
      else if (a.size() == 3)
        front = true;
      prot(s[i]);
      if (front) {
        a.push_back((s[i] - '0') % 3);
        front = false;
      }
    }
  }
  prot('0');
  cout << ans;
  return 0;
}
