import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const T = readToken();
      const L = cast(int)(T.length);
      
      long ans;
      auto used = new bool[L];
      
      int len;
      foreach (i; 0 .. L) {
        if (T[i] == '1') {
          used[i] = true;
          ++len;
          ans += (len + 1) / 2;
        }
      }
      int num;
      foreach (i; 0 .. L) {
        if (T[i] == '1') {
          ++num;
        } else {
          if (num % 2 != 0) {
            used[i] = true;
            ++num;
            ++len;
            ans += (len + 1) / 2;
          }
        }
      }
      
      auto poss = new int[L];
      poss[] = -1;
      int pos;
      foreach (i; 0 .. L) {
        if (used[i]) {
          poss[i] = pos++;
        }
      }
      debug {
        writeln("T = ", T);
        writeln(ans, " ", used, " ", len, " ", num, " ", poss);
      }
      
      int head = (len + 1) / 2;
      int tail0, tail1;
      foreach_reverse (i; 0 .. L) {
        if (T[i] == '1') {
          if (poss[i] % 2 == 0) {
            --head;
            ++tail0;
          } else {
            ++tail1;
          }
        } else {
          if (!used[i]) {
            swap(tail0, tail1);
            debug {
              writeln(i, ": ", head, " ", tail0, " ", tail1);
            }
            ans += head + tail0;
          }
        }
      }
      writeln(ans);
      
      debug {
        int brt;
        auto perm = iota(L).array;
        do {
          int score;
          auto vis = new bool[L];
          foreach (i; perm) {
            vis[i] = true;
            int p;
            foreach (j; 0 .. L) {
              if (vis[j]) {
                if (T[j] == '1' && p % 2 == 0) {
                  ++score;
                }
                ++p;
              }
            }
          }
          chmax(brt, score);
        } while (perm.nextPermutation);
        writeln("brt = ", brt);
        assert(brt == ans);
      }
    }
  } catch (EOFException e) {
  }
}
