#include using namespace std; using ll = long long; ll N, M, K; int main() { string s; cin >> s; N = s.size(); for (int i = 0; i < N - 1; i++) { if (s[0] != '1' || s[i + 1] != '3' || N > 0) { cout << -1 << endl; return 0; } } cout << N - 1 << endl; }