#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    long long n;
    string s;
    cin >> s;
    n = s.length();
    vector<long long> a(n);
    long long ans = 0;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      a[i] = (s[i] - '0') % 3;
      ans += (a[i] == 0);
    }
    for (long long i = 0; i < n; i++) {
      if (a[i] == 0) {
        sum = 0;
        continue;
      }
      if (a[i] == 1) {
        if (i + 1 < n && a[i + 1] == 2) {
          ans++;
          i++;
        } else if (i + 2 < n && a[i + 1] == 1 && a[i + 2] == 1) {
          ans++;
          i++;
          i++;
        }
      } else if (a[i] == 2) {
        if (i + 1 < n && a[i + 1] == 1) {
          ans++;
          i++;
        } else if (i + 2 < n && a[i + 1] == 2 && a[i + 2] == 2) {
          ans++;
          i++;
          i++;
        }
      }
    }
    cout << ans;
  }
  return 0;
}
