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