#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  bool ok = true;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      if (isupper(S[i])){
        ok = false;
      }
    } else {
      if (islower(S[i])){
        ok = false;
      }
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things. 
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

int main(){

	
	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string n;
    cin>>n;

    ll ans=INT_MAX;
    ll sz=n.size();

    for(int i=0;i<(1<<sz)-1;i++){
    	ll c=0;
    	for(int j=0;j<sz;j++){
    		if(((i>>j)&1)==0){
    			c+=n[j]-'0';
    		}
    	}
    	// cerr<<i<<" "<<c<<endl;

    	if(c%3==0){
    		ans=min(ans,(ll)__builtin_popcount(i));
    	}
    }

    if(ans==INT_MAX){
    	cout<<-1<<endl;
    }
    else{
    	cout<<ans<<endl;
    }

}