#include using namespace std; int main() { string s; cin >> s; if (s[0] != '1' || s.size() == 1) { cout << -1 << endl; return 0; } for (int i = 0; i < s.size(); i++) { if (i != 0 && s[i] != '3') { cout << -1 << endl; return 0; } } cout << s.size()-1 << endl; return 0; }