#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  ;
  string str;
  cin >> str;
  vector<long long> vec;
  int pre = str[0] - '0', val, total = 0, temp = 0;
  if (pre % 3 == 0) {
    total++;
    pre = 0;
  } else
    vec.push_back(pre);
  pre = 0;
  for (int i = 1; i < str.length(); ++i) {
    val = str[i] - '0';
    if (val % 3 == 0) {
      total++;
      vec.resize(0);
    } else {
      pre = val;
      for (auto j = vec.rbegin(); j != vec.rend(); ++j) {
        if ((*j + pre) % 3 == 0) {
          total++;
          temp = 1;
          vec.resize(0);
          break;
        } else {
          pre += *j;
        }
      }
      if (!temp) vec.push_back(val);
      temp = 0;
    }
  }
  cout << total;
  return 0;
}
