#include using namespace std; int main() { string s; cin >> s; int len = s.size(); int c = 0; for (int i = 0; i < len; i++) { if (i == 0) { if (s.at(i) != '1') { cout << -1 << endl; return 0; } } else { if (s.at(i) == '3') { c++; } else { cout << -1 << endl; return 0; } } } cout << c << endl; /* int64_t N; cin >> N; if (N < 13) { cout << -1 << endl; return 0; } int c = 0; while (N > 0) { if (N % 10 == 3) { c++; N /= 10; if (N < 10) { if (N == 1) { cout << c << endl; return 0; } else { cout << -1 << endl; return 0; } } } else { cout << -1 << endl; break; } } */ }