#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int a[10];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.size(), r = 0;
  vector<int> v(n + 1);
  a[0] = 0, a[1] = -1, a[2] = -1;
  for (int i = 1; i <= n; ++i) {
    r += (s[i - 1] - '0');
    r %= 3;
    v[i] = v[i - 1];
    if (a[r] != -1) v[i] = max(v[i], v[a[r]] + 1);
    a[r] = i;
  }
  cout << v[n];
}
