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