#include #define int long long using namespace std; signed main() { string S; cin >> S; bool fg = true; if( S.size() == 1 ) fg = false; for( int i = 0; i < S.size(); i++ ){ if( i == 0 && S.at(i) != '1' ) fg = false; if( i > 0 && S.at(i) != '3' ) fg = false; } if( fg ) cout << (int)S.size() - 1 << endl; else cout << -1 << endl; }