#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
void solve() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> arr(n + 1);
  int i;
  for (i = 1; i < n + 1; i++) arr[i] = s[i - 1] - '0', arr[i] += arr[i - 1];
  int set[3] = {-1, -1, -1};
  int count = 0;
  for (i = 0; i < n + 1; i++) {
    int rem = arr[i] % 3;
    if (set[rem] == -1) {
      set[rem] = i;
    } else {
      count++;
      memset(set, -1, sizeof(set));
      set[rem] = i;
    }
  }
  cout << count << endl;
}
