n = input()
a = [int(i) for i in n]
tmp = 0
cnt = 0
ans = 0
for i in a:
t = i % 3
tmp = (tmp + t) % 3
cnt += 1
if t == 0 or tmp == 0 or cnt == 3:
ans += 1
cnt = 0
tmp = 0
print(ans)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+100;
const ll M=998244353;
ll dp[N][3];//第i位的余数为0,1,2;
int main() {
string s;
cin>>s;
ll ans=0,st=0;
dp[0][0]=dp[0][1]=dp[0][2]=0;
for(int i=0;i<s.size();i++)
{
ll zhi=(s[i]-'0')%3;
if(zhi==0)
{
dp[i][2]=dp[i][1]=dp[i][0]=0;
ans++;
}
else if(zhi==1)
{
if(dp[i-1][2])
{
dp[i][2]=dp[i][1]=dp[i][0]=0;
ans++;
}
else
{
if(dp[i-1][1])dp[i][2]=1;
else dp[i][2]=0;
dp[i][1]=1;
}
}
else if(zhi==2)
{
if(dp[i-1][1])
{
dp[i][2]=0;dp[i][1]=0;dp[i][0]=0;
ans++;
}
else
{
if(dp[i-1][2])dp[i][1]=1;
else dp[i][1]=dp[i-1][1];dp[i][2]=1;
}
}
}
cout<<ans<<endl;
return 0;
}
//111112122222221212
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |