#include using namespace std; #define chmax(x, y) x = max(x, y) int main(){ string s; cin >> s; int n = s.length(); int ans = -1; if(n == 1 || s[0] != '1'){ cout << ans << endl; return 0; } for(int i = 1; i < n; ++i){ if(s[i] != '3'){ cout << ans << endl; return 0; } } ans = n - 1; cout << ans << endl; }