#include #include #include #include #define int long long using namespace std; signed main() { string s; cin >> s; bool b = 1; if (s[0] != '1')b = 0; for (int i = 1; i < s.size(); i++)if (s[i] != '3')b = 0; if (b)cout << s.size() - 1 << endl; else cout << -1 << endl; }