#include <bits/stdc++.h>
using namespace std;
int READ_INT() {
  int temp;
  cin >> temp;
  return temp;
}
long long int READ_LONG() {
  long long int temp;
  cin >> temp;
  return temp;
}
string READ_STRING() {
  string temp;
  cin >> temp;
  return temp;
}
template <typename T_vector>
void output_vector(const T_vector &v, bool add_one = false, int start = -1,
                   int end = -1) {
  if (start < 0) start = 0;
  if (end < 0) end = int(v.size());
  for (int i = start; i < end; i++)
    cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
const long double p = 3.14159265358979323846;
const long long INF = 1e+5;
const int N = 1e+5;
long long int inverse(long long int i) {
  if (i == 1) return 1;
  return (1000000007 -
          ((1000000007 / i) * inverse(1000000007 % i)) % 1000000007 +
          1000000007) %
         1000000007;
}
long long int POW(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a % 1000000007;
  long long int temp = POW(a, b / 2);
  if (b % 2 == 0)
    return (temp * temp) % 1000000007;
  else
    return (((temp * temp) % 1000000007) * a) % 1000000007;
}
void bootcoder() {
  int ans = 0, sum = 0;
  string s;
  cin >> s;
  int size = s.length();
  sum = 0;
  int prev = 0;
  for (int i = 0; i < size; i++) {
    int digit = s[i] - '0';
    if (digit % 3 == 0 || (sum + digit) % 3 == 0 || (prev + digit) % 3 == 0) {
      ans++;
      sum = 0;
      prev = 0;
    } else {
      sum += digit;
      prev = digit;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int test;
  test = 1;
  while (test--) {
    bootcoder();
  }
}
