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