program daugyba_a_la_russe;
  var sand, m, n: longint;
begin
  readln (m, n);
  sand := 0;
  repeat
    if odd(m)
       then begin
              sand := sand + n;
              writeln (sand: 10);
            end;
      m := m div 2;
      if m > 0  { apsisaugome nuo galimo perpildymo }
         then n := n + n;
  until m < 1
end.