#include <bits/stdc++.h>
using namespace std;
string s;
int cnt = 0;
char a[4];
set<char> o, x;
void dfs(int depth)
{
	if (depth > 3)
	{
		bool flag = true;
		for (char c : o)
		{
			if (0 == count(a, a + 4, c))
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			for (char c : x)
			{
				if (count(a, a + 4, c))
				{
					flag = false;
					break;
				}
			}
		}
		cnt += flag;
		return;
	}
	for (int i = 0; i < 10; ++i)
	{
		a[depth] = '0' + i;
		dfs(depth + 1);
	}
}
int main()
{
	cin >> s;
	for (int i = 0; i < 10; ++i)
	{
		if ('o' == s[i])
		{
			o.insert('0' + i);
		}
		else if ('x' == s[i])
		{
			x.insert('0' + i);
		}
	}
	if (count(s.begin(), s.end(), 'o') > 4)
	{
		cout << 0 << endl;
	}
	else
	{
		dfs(0);
		cout << cnt << endl;
	}
}
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
int INF =1001001001;
int main()
{
string s;
cin>>s;
int n=s.size();
vector<int>c(3);
rep(i,n)c[(s[i]-'0')%3]++;

int sum=0;
rep(i,3)sum+=c[i]*i;
int ans =INF;
rep(i1,3)rep(i2,3)
{
if(c[1]<i1)continue;
if(c[2]<i2)continue;
if(i1+i2==n)continue;

int temp=sum;
temp-=(1*i1+2*i2);
if(temp%3==0)ans=min(ans,i1+i2);

}
if(ans==INF)ans =-1;
cout <<ans;
return 0;

}