#include "bits/stdc++.h" using namespace std; void solve() { string S; cin >> S; bool ok = S[0] == '1'; for (int i = 1; i < (int)S.size(); i++) { ok &= S[i] == '3'; } cout << (ok ? (int)S.size()-1 : -1) << endl; } int main(void) { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }