#include #include #include #include #include #include #include #include #include "bits/stdc++.h" using namespace std; #define INF 100000000 int main() { string N; cin >> N; bool flag = N[0] == '1' ? true : false; int counter = 0; for (int i = 1; i < N.size(); i++) { if (N[i] == '3') { counter += 1; } else { flag = false; } } if (!flag || counter == 0) { cout << -1 << endl; } else { cout << counter << endl; } }