#include #include void solve() { std::string s; std::cin >> s; int ans = s.length() - 1; bool ok = ans > 0; for (int i = 0; i < (int)s.length(); ++i) { if ((i == 0 && s[i] != '1') || (i > 0 && s[i] != '3')) { ok = false; } } std::cout << (ok ? ans : -1) << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }