#include <bits/stdc++.h>
using namespace std;
const int N = 10010, M = 100010;
const int inf = 0x7fffffff;
int n, m, s, t, maxflow;
int s1, s2, s3;
int tot, fir[N];
int dep[N];
struct edge {
  int u, v, w, next;
} a[M * 2];
void New(int from, int to, int wgt) {
  a[++tot].u = from;
  a[tot].v = to;
  a[tot].w = wgt;
  a[tot].next = fir[from];
  fir[from] = tot;
}
bool bfs() {
  memset(dep, 0, sizeof(dep));
  int dl[N];
  int head = 0, tail = 1;
  dep[s] = 1;
  dl[1] = s;
  while (head < tail) {
    int wz = dl[++head];
    for (int now = fir[wz]; now; now = a[now].next) {
      if (!dep[a[now].v] && a[now].w) {
        dl[++tail] = a[now].v;
        dep[a[now].v] = dep[wz] + 1;
        if (a[now].v == t) return 1;
      }
    }
  }
  return 0;
}
int dinic(int wz, int flow) {
  if (wz == t) return flow;
  int rest = flow, k;
  for (int now = fir[wz]; now && rest; now = a[now].next) {
    if (dep[a[now].v] == dep[wz] + 1 && a[now].w) {
      k = dinic(a[now].v, min(rest, a[now].w));
      if (!k) dep[a[now].v] = 0;
      a[now].w -= k;
      if (now % 2)
        a[now + 1].w += k;
      else
        a[now - 1].w += k;
      rest -= k;
    }
  }
  return flow - rest;
}
const int mod = 1e9 + 7;
int summ, a1, a2, a3, b1, b2, b3;
void solve() {
  cin >> summ >> a1 >> a2 >> a3 >> b1 >> b2 >> b3;
  int flow;
  New(1, 2, summ);
  New(2, 1, 0);
  New(1, 3, summ);
  New(3, 1, 0);
  New(1, 4, summ);
  New(4, 1, 0);
  New(2, 5, b1);
  New(5, 2, 0);
  New(2, 6, b1);
  New(6, 2, 0);
  New(3, 6, b2);
  New(6, 3, 0);
  New(3, 7, b2);
  New(7, 3, 0);
  New(4, 7, b3);
  New(7, 4, 0);
  New(4, 5, b3);
  New(5, 4, 0);
  New(5, 8, a1);
  New(8, 5, 0);
  New(6, 8, a2);
  New(8, 6, 0);
  New(7, 8, a3);
  New(8, 7, 0);
  n = 8;
  s = 1;
  t = 8;
  while (bfs()) {
    while (flow = dinic(s, inf)) {
      maxflow += flow;
    }
  }
  cout << summ - maxflow << " ";
  cout << min(a1, b2) + min(a2, b3) + min(a3, b1) << endl;
}
int main() {
  solve();
  return 0;
}
