/* No.791 うし数列 https://yukicoder.me/problems/no/791 */ #include using namespace std; int count_string(string n) { int cnt = 0; for (auto ch : n) if (ch == '3') cnt++; return cnt; } int main() { ios::sync_with_stdio(0); cin.tie(0); string n; cin >> n; if (n[0] != '1' || n.size() == 1) { cout << -1 << endl; return 0; } int cnt = count_string(n); if (cnt == (int)n.size() - 1) { cout << cnt << endl; } else { cout << -1 << endl; } }