#include using namespace std; using ll = long long; int 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') { cout << -1 << endl; return 0; } } cout << (N == 1 ? -1 : N - 1) << endl; }