#include using namespace std; typedef long long int ll; int main() { string s; cin >> s; if (s[0] != '1') { cout << -1 << endl; return 0; } int res = 0; for (int i = 1; i < s.size(); i++) { if (s[i] == '3') { res++; } else { cout << -1 << endl; return 0; } } cout << res << endl; }