#include #define rep(i, n) for (int i = 0; i < n; ++i) using ll = long long; using namespace std; const int INF = 1e9; int main() { string s; cin >> s; int cnt = 0; for (int i = 1; i < s.size(); ++i) { if(s[i]!='3'){ cout << -1 << endl; return 0; } else ++cnt; } cout << cnt << endl; return 0; }