#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string N; cin >> N; bool flg = true; if (N.size() == (unsigned int)(1)) { flg = false; } if (N[0] != '1') { flg = false; } for (unsigned int i = 1; i < N.size(); i++) { if (N[i] != '3') { flg = false; } } if (flg) { cout << N.size() - 1 << endl; } else { cout << -1 << endl; } return 0; }