#include<iostream> #include<vector> #include<algorithm> #include<functional> #include<queue> #include<stack> #include<set> #include<map> #include<unordered_map> #include<climits> #include<cstdlib> #include<cmath> #include<string> #include<iomanip> #include<bitset> using namespace std; #define ll long long int ll const MOD = 1000000007; ll const INF = (long long int)1 << 61; int main(){ cin.tie(0); ios::sync_with_stdio(false); string str; cin >> str; bool ok = true; if(str[0] != '1'){ ok = false; } for(int i = 1; i < str.size(); i++){ if(str[i] != '3'){ ok = false; } } if(ok && str.size() > 1){ cout << str.size() - 1 << endl; }else{ cout << -1 << endl; } return 0; }