#include #include #include using namespace std; int main() { string N; cin >> N; if (regex_match(N, regex("13+"))) cout << N.size() - 1; else cout << -1; }