#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 1000;
const int mod = 998244353;
int res, sum, r, n;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  for (char c : s) {
    r = (c - '0') % 3;
    sum += r;
    ++n;
    if (n == 3 || r == 0 || sum % 3 == 0) res++, sum = n = 0;
  }
  cout << res;
}
