#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 998244353; const ll INF = (ll)1000000007 * 1000000007; typedef pair P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef long double ld; typedef complex Point; const ld eps = 1e-2; const ld pi = acos(-1.0); int main() { string n; cin >> n; bool f = true; if (n[0] != '1')f = false; Rep(i, 1, n.size()) { if (n[i] != '3')f = false; } if (!f) { cout << -1 << endl; } else { cout << n.size() - 1 << endl; } //stop return 0; }