#include #include #include using namespace std; int main(){ string s; cin >> s; int n = s.size(); int ans = 0; for ( int i = 0; i < n; i ++ ) { if ( i == 0 && s[i] != '1' ) ans = -1; else if ( i > 0 && s[i] != '3' ) ans = -1; } if ( ans != -1 && n > 1 ) ans = n-1; if ( ans == 0 ) ans = -1; cout << ans << endl; return 0; }