#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
int main() {
  string s;
  cin >> s;
  long long dem = 0, tmp = 0, tmp2 = 0, save = 0;
  for (long long i = 0; i < s.length(); i++) {
    if ((s[i] - '0') % 3 == 0) {
      dem++;
      tmp = 0;
      tmp2 = 0;
      save = 0;
    } else {
      tmp2 = (s[i] - '0') + save;
      if (tmp2 % 3 == 0) {
        tmp2 = 0;
        tmp = 0;
        save = 0;
        dem++;
      } else {
        save = s[i] - '0';
        tmp += s[i] - '0';
        if (tmp % 3 == 0) {
          dem++;
          tmp = 0;
          save = 0;
          tmp2 = 0;
        }
      }
    }
  }
  cout << dem;
}
