#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; cout << (b ? s.size() - 1 : -1) << endl; }