#include using namespace std; int main(){ string S; cin >> S; for(int i = 1; i < S.size(); i++) { if(S[i] != '3') { cout << "-1\n"; return 0; } } if(S.size() >= 2) cout << S.size() - 1 << endl; else cout << -1 << endl; }