#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  char s[200005];
  scanf("%s", s);
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    a[i] = s[i] - '0';
  }
  int sum = 0;
  int k = 0;
  int ans = 0;
  while (k < len) {
    if (a[k] % 3 == 0) {
      ans++;
      k++;
    } else {
      int yushu1, yushu2, yushu3;
      if ((k + 2) < len) {
        yushu1 = a[k] % 3;
        yushu2 = a[k + 1] % 3;
        yushu3 = a[k + 2] % 3;
        if (yushu1 == 1) {
          if (yushu2 == 0) {
            ans++;
            k = k + 2;
          } else if (yushu2 == 1) {
            ans++;
            k = k + 3;
          } else if (yushu2 == 2) {
            ans++;
            k = k + 2;
          }
        } else if (yushu1 == 2) {
          if (yushu2 == 0) {
            ans++;
            k = k + 2;
          } else if (yushu2 == 1) {
            ans++;
            k = k + 2;
          } else if (yushu2 == 2) {
            if (yushu3 == 1) {
              ans++;
              k += 3;
            } else if (yushu3 == 0) {
              ans++;
              k += 3;
            } else {
              ans++;
              k += 3;
            }
          }
        }
      } else if ((k + 2) >= len && (k + 1) < len) {
        yushu1 = a[k] % 3;
        yushu2 = a[k + 1] % 3;
        if (yushu1 == 1) {
          if (yushu2 == 2) {
            ans++;
            k += 2;
          } else if (yushu2 == 1) {
            k += 2;
          } else if (yushu2 == 0) {
            k += 2;
            ans++;
          }
        } else if (yushu1 == 2) {
          if (yushu2 == 1) {
            ans++;
            k += 2;
          } else if (yushu2 == 2) {
            k += 2;
          } else if (yushu2 == 0) {
            ans++;
            k += 2;
          }
        }
      } else if ((k + 1) >= len) {
        k++;
      }
    }
  }
  printf("%d", ans);
}
