#include using namespace std; int main(int argc, char ** argv){ char N; cin >> N; if(N != '1'){ cout << -1; } else{ int digit = 0; while(cin >> N){ if(N != '3'){ digit = -1; break; } digit++; } if(digit == 0) cout << -1; else cout << digit; } }