#include using namespace std; int main() { char n[102] = {0}; cin >> n; if(n[0] != '1'){ cout << -1 << endl; return 0; } int ans = 0, i = 1; while(n[i] != 0){ if(n[i] == '3') ++ans; else{ cout << -1 << endl; return 0; } ++i; } cout << (ans == 0 ? -1 : ans) << endl; return 0; }