#include using namespace std; int main(){ long long n, ans = 0; cin >> n; while(n >= 10){ if(n % 10 == 3){ ans++; n /= 10; }else{ ans = 0; break; } } if(ans > 0 && n == 1) cout << ans << endl; else cout << -1 << endl; }