#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  int l = 0;
  long long int sum = 0;
  for (int i = 0; i < s.length(); i++) {
    l++;
    sum += s[i] - '0';
    if ((s[i] - '0') % 3 == 0 || sum % 3 == 0 || l >= 3) {
      sum = 0;
      cnt++;
      l = 0;
    }
  }
  cout << cnt << endl;
}
