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