uses
  Math;

const
  MAXN = 100;

var
  a1, a2, a3, b1, b2, b3, ans : integer;

procedure pair(var a : integer; var b : integer);
var
  m : integer;
begin
  m := min(a, b);
  ans := ans + m;
  a := a - m;
  b := b - m;
end;

begin
  reset(input, 'computers.in');
  rewrite(output, 'computers.out');
  read(a1, a2, a3);
  read(b1, b2, b3);
  ans := 0;
  assert((0 <= a1) and (a1 <= MAXN));
  assert((0 <= a2) and (a2 <= MAXN));
  assert((0 <= a3) and (a3 <= MAXN));
  assert((0 <= b1) and (b1 <= MAXN));
  assert((0 <= b2) and (b2 <= MAXN));
  assert((0 <= b3) and (b3 <= MAXN));

  pair(a1, b3);
  pair(b1, a3);

  pair(a2, b3);
  pair(b2, a3);

  pair(a1, b1);
  pair(a2, b2);
  pair(a3, b3);

  writeln(ans);
end.