#include #include #include using namespace std; int main() { string A; int cnt = 0; cin >> A; const int Z = A.size(); if (Z == 1) { cout << -1 << endl; } else { if (A.at(0) != '1') { cnt++; } for (int i = 1; i < Z; i++) { if (A.at(i) != '3') { cnt++; } } if (cnt == 0) { cout << Z - 1 << endl; } if (cnt != 0) { cout << -1 << endl; } } }