#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.tie(0);
  string s;
  int vis[3] = {1, 0, 0};
  int cnt = 0;
  int ans = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    cnt += s[i] - '0';
    cnt %= 3;
    if (vis[cnt]) {
      ans++;
      vis[1] = vis[2] = 0;
      cnt = 0;
    } else {
      vis[cnt] = 1;
    }
  }
  cout << ans << endl;
}
