#include #include #include int main() { //std::ifstream inf("Text.txt"); std::cin.rdbuf(inf.rdbuf()); std::string S; std::cin >> S; int ans = 0; if (S[0] != '1') { std::cout << "-1" << std::endl; return 0; } if (S.length() == 1 && S[0] == '1') { std::cout << "-1" << std::endl; return 0; } for (unsigned int i = 1; i < S.length(); i++) { if (S[i] == '3') { ans++; } else { ans = -1; break; } } std::cout << ans << std::endl; return 0; }