#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; if (s[0] != '1') { cout << -1 << endl; return 0; } if ((int) s.length() == 1) { cout << -1 << endl; return 0; } for (int i = 2; i < (int) s.length(); i++) { if (s[i] != '3') { cout << -1 << endl; return 0; } } cout << (int) s.length() - 1 << endl; return 0; }