import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  string S = readln.chomp;
  short flag;
  int sum;

  foreach (i; 0..S.length + 1) {
    string fs = ("%." ~ (S.length - 1).to!string ~ "b").format(flag++);

    string formula;

    foreach (j, ch; S) {
      if (0 < j && j < S.length && fs[j - 1] == '1') {
        formula ~= '+';
      }

      formula ~= ch;
    }

    sum += formula.split("+").to!(int[]).sum;
  }

  writeln(sum);
}
