#include using namespace std; typedef long long LL; int main() { // 1. 入力情報取得. string N; cin >> N; // 2. 何項目目? LL l = N.size(); LL count3 = 0; for(int i = 0; i < l; i++) if(N[i] == '3') count3++; LL ans = -1; if(l - 1 == count3 && l > 1) ans = count3; // 3. 出力. cout << ans << endl; return 0; }