#include <bits/stdc++.h>
using namespace std;
void Fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
void File() {}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return (a / gcd(a, b)) * b; }
struct mul {
  long long p1 = 0, p2 = 0, ind = 0, size = 0;
  double avg = 0.0;
  bool operator<(mul other) const {
    if (avg == other.avg) {
      return ind > other.ind;
    } else {
      return avg > other.avg;
    }
  }
};
void printNumber(int n) {
  if (n <= 1) {
    cout << n;
    return;
  }
  printNumber(n >> 1);
  cout << (n & 1);
}
int countBits1(int num) {
  int cnt = 0;
  while (num) {
    cnt += (num & 1);
    num >>= 1;
  }
  return cnt;
}
int getbit(int n, int idx) { return ((n >> idx) & 1); }
int setBit1(int num, int idx) { return num | (1 << idx); }
int setBit0(int num, int idx) { return num & ~(1 << idx); }
int flibBit(int num, int idx) { return num ^ (1 << idx); }
int countNumBit2(int num) {
  int ret = 0;
  while (num) {
    num &= (num - 1);
    ++ret;
  }
  return ret;
}
bool isPowerOfTwo(long long num) { return (num & num - 1) == 0; }
int turnOnfirstZero(int S) { return S | S + 1; }
int turnOfffisrt1(int S) { return S & S - 1; }
int turnOnLastConsecutiveZeroes(int S) { return S | S - 1; }
int turnOffLastConsecutiveOnes(int S) { return S & S + 1; }
bool check(queue<char> q, long long& sum) {
  int h = sum, p = 0;
  while (!q.empty()) {
    if (h % 3 == 0) {
      sum = 0;
      return 1;
    }
    p = q.front() - '0';
    h -= p;
    q.pop();
  }
  return 0;
}
int main() {
  Fast();
  File();
  string s;
  cin >> s;
  queue<char> v;
  long long ans = 0, x = 0, c = 0, p = 0;
  for (int i = 0; i < s.size(); i++) {
    v.push(s[i]);
    p = s[i] - '0';
    x += (pow(10, c) * p);
    c++;
    if (check(v, x)) {
      ans++;
      c = 0;
      while (!v.empty()) {
        v.pop();
      }
    }
  }
  cout << ans << "\n";
}
