#include using namespace std; int main(void){ char c; int i=0; cin >> c; if(c != '1'){ cout << -1 << endl; return 0; } while(cin >> c){ if(c != '3'){ i = -1; break; } i++; } if(i == 0){ i = -1; } cout << i << endl; return 0; }