#include "bits/stdc++.h" using namespace std; bool ok = true; int main() { string h; cin >> h; for (int i = 0; i < h.length(); ++i) { if (i == 0 && h[0] != '1') { ok = false; } else if (i != 0 && h[i] != '3') { ok = false; } } if (!ok || h.length() == 1) { cout << -1 << endl; } else { cout << h.length() - 1 << endl; } }