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