#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  int a[MAX];
  for (int i = 0; i < n; i++) {
    int tm = s[i] - '0';
    a[i] = tm % 3;
  }
  for (int i = n; i < n + 5; i++) a[i] = 10;
  int i = 0;
  int cn = 0;
  while (i < n) {
    if (a[i] == 0) {
      cn++;
      i++;
      continue;
    }
    if (a[i] == 1) {
      if (a[i + 1] == 2) {
        cn++;
        i += 2;
        continue;
      }
      if (a[i + 1] == 1 and a[i + 2] == 1) {
        cn++;
        i += 3;
        continue;
      }
      i++;
      continue;
    }
    if (a[i] == 2) {
      if (a[i + 1] == 1) {
        cn++;
        i += 2;
        continue;
      }
      if (a[i + 1] == 2 and a[i + 2] == 2) {
        cn++;
        i += 3;
        continue;
      }
      i++;
      continue;
    }
  }
  cout << cn;
}
