#include "bits/stdc++.h" #define LF '\n' #define ALL(x) x.begin(), x.end() #define LEN(x) (int)x.size() #define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0) using namespace std; typedef int64_t i64; typedef pair pii; templateinline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;} templateinline bool chmin(A &a, const B &b){return bvoid dump(Itr begin, Itr end) { for(;begin != end; ++begin) clog << ' ' << *begin; clog << LF; } signed main() { string s; cin >> s; if (s[0] != '1' || s.length() <= 1 || !all_of(s.begin()+1, s.end(), [](const auto &c){ return c == '3'; })) { cout << -1 << endl; } else { cout << s.length() - 1 << endl; } return 0; }