#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
int A[MAX], sum[MAX], one[MAX], two[MAX], zero[MAX];
int main() {
  string S;
  cin >> S;
  int N = S.length();
  for (int i = 1; i <= N; i++) {
    A[i] = (S[i - 1] - '0') % 3;
  }
  one[0] = -1;
  two[0] = -1;
  for (int i = 1; i <= N; i++) {
    sum[i] = (sum[i - 1] + A[i]) % 3;
    if (sum[i] == 0) {
      zero[i] = i;
      one[i] = one[i - 1];
      two[i] = two[i - 1];
    } else if (sum[i] == 1) {
      zero[i] = zero[i - 1];
      one[i] = i;
      two[i] = two[i - 1];
    } else {
      zero[i] = zero[i - 1];
      one[i] = one[i - 1];
      two[i] = i;
    }
  }
  int last = 0, ans = 0;
  for (int i = 1; i <= N; i++) {
    if (sum[i] == 0) {
      if (zero[i - 1] >= last) {
        last = i;
        ans += 1;
      }
    }
    if (sum[i] == 1) {
      if (one[i - 1] >= last) {
        last = i;
        ans += 1;
      }
    }
    if (sum[i] == 2) {
      if (two[i - 1] >= last) {
        last = i;
        ans += 1;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
