#include #include using namespace std; using namespace atcoder; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } int main() { string S; cin >> S; reverse(S.begin(),S.end()); long long movedNum = 0; long long wall = -1; long long state_one = 0; long long res = 0; rep(i,S.size()){ if(state_one == 0){ if(S[i] == '1'){ state_one = 1; } }else{ state_one = 0; if(S[i] == '0'){ // wall = i - 1; movedNum = 0; }else{ res += i-wall-2-2*movedNum; movedNum++; } } } cout << res << endl; }