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