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