#include <cstdio>
#include <cassert>
#include <algorithm>

using namespace std;

int res = 0;
void op( int &a, int &b ) { int d = min(a, b); a -= d, b -= d, res += d; }

int main()
{
  freopen("computers.in", "r", stdin);
  freopen("computers.out", "w", stdout);

  int a1, a2, a3;
  assert(scanf("%d%d%d", &a1, &a2, &a3) == 3);
  assert(0 <= a1 && a1 <= 100);
  assert(0 <= a2 && a2 <= 100);
  assert(0 <= a3 && a3 <= 100);
  int b1, b2, b3;
  assert(scanf("%d%d%d", &b1, &b2, &b3) == 3);
  assert(0 <= b1 && b1 <= 100);
  assert(0 <= b2 && b2 <= 100);
  assert(0 <= b3 && b3 <= 100);
  assert(a1 + a2 + a3 == b1 + b2 + b3);
  op(a1, b1); op(a2, b2);
  op(a1, b3); op(a2, b3);
  op(a3, b1); op(a3, b2);
  op(a3, b3);
  printf("%d\n", res);
  return 0;
}
