#include <bits/stdc++.h>
using namespace std;
char a[200010];
int main() {
  cin >> a;
  int sum = 0, cnt = 0, n = 0;
  for (int i = 0; i < strlen(a); i++) {
    int c = a[i] - '0';
    sum += c;
    n++;
    if (c % 3 == 0 || sum % 3 == 0 || n == 3) {
      sum = 0;
      n = 0;
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
