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