#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ara[300000];
  ara[0] = 0;
  for (int i = 0; i < s.length(); i++) {
    ara[i + 1] = ara[i] + (s[i] - 48);
  }
  int pos = 0, cnt = 0;
  for (int i = 1; i <= s.length(); i++) {
    for (int j = pos; j < i; j++) {
      int x = ara[i] - ara[j];
      if (x % 3 == 0) {
        cnt++;
        pos = i;
        break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
