#include using namespace std; using ll = long long; using P = pair; using PL = pair; // Welcome to my source code! int main() { string s; cin >> s; if (s[0] != '1') { cout << -1 << endl; return 0; } int n = s.size(); for (int i = 1; i < n; i++) { if (s[i] != '3') { cout << -1 << endl; return 0; } } cout << (n - 1 ? n - 1 : -1) << endl; }