#include <bits/stdc++.h>
using namespace std;
char s[200005];
int a[200005];
int main() {
  scanf("%s", s);
  int len = strlen(s), ans = 0, cnt = 0, sum = 0;
  for (int i = 0; i < len; i++) {
    int temp = s[i] - 48;
    if (temp % 3 == 0) {
      ans++;
      cnt = 0;
      sum = 0;
    } else {
      a[cnt++] = temp % 3;
      sum += temp;
      if (sum % 3 == 0) {
        ans++;
        sum = 0;
        cnt = 0;
      } else {
        int t = 0;
        for (int j = cnt - 1; j >= 0; j--) {
          t += a[j];
          if (t % 3 == 0) {
            ans++;
            cnt = 0;
            sum = 0;
            break;
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
