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