#include #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long #define endl '\n' using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int cnt = 0; if (s[0] != '1') { cout << -1 << endl; return 0; } for (int i = 1; i < s.size(); i++) { if (s[i] != '3') { cout << -1 << endl; return 0; } else { cnt++; } } cout << cnt << endl; return 0; }