#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string S; cin >> S; if (S[0] == '1' && (int)S.size() > 1) { for (int i = 1; i < (int)S.size(); i++) { if (S[i] != '3') { cout << -1 << '\n'; return 0; } } cout << (int)S.size() - 1 << '\n'; } else { cout << -1 << '\n'; } return 0; }