#include <bits/stdc++.h>
using namespace std;
long long A[4], B[4], AA[4], BB[4];
pair<pair<long long, long long>, pair<long long, long long> > v[7], vv[7];
long long solve(long long pos, long long lost) {
  if (pos > 6) return lost;
  long long x = v[pos].first.first;
  long long y = v[pos].first.second;
  long long xx = v[pos].second.first;
  long long yy = v[pos].second.second;
  long long p = min(AA[x], BB[y]);
  long long val = 0;
  val += p;
  AA[x] -= p;
  BB[y] -= p;
  long long pp = min(AA[xx], BB[yy]);
  val += pp;
  AA[xx] -= pp;
  BB[yy] -= pp;
  long long an1 = solve(pos + 1, lost + val);
  AA[x] += p;
  BB[y] += p;
  AA[xx] += pp;
  BB[yy] += pp;
  xx = v[pos].first.first;
  yy = v[pos].first.second;
  x = v[pos].second.first;
  y = v[pos].second.second;
  p = min(AA[x], BB[y]);
  val = p;
  AA[x] -= p;
  BB[y] -= p;
  pp = min(AA[xx], BB[yy]);
  val += pp;
  AA[xx] -= pp;
  BB[yy] -= pp;
  long long an2 = solve(pos + 1, lost + val);
  AA[x] += p;
  BB[y] += p;
  AA[xx] += pp;
  BB[yy] += pp;
  return max(an2, an1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  cin >> A[1] >> A[3] >> A[2];
  cin >> B[1] >> B[3] >> B[2];
  for (int i = 1; i <= 3; i++) AA[i] = A[i], BB[i] = B[i];
  vv[1] = {{1, 1}, {1, 2}};
  vv[2] = {{2, 2}, {2, 3}};
  vv[3] = {{3, 3}, {3, 1}};
  long long A[] = {1, 2, 3}, an1 = 0;
  do {
    v[A[0]] = vv[1];
    v[A[1]] = vv[2];
    v[A[2]] = vv[3];
    long long nn = solve(1, 0);
    an1 = max(an1, nn);
  } while (next_permutation(A, A + 3));
  an1 = n - an1;
  long long p = min(BB[1], AA[2]);
  long long bl = 0;
  bl += p;
  BB[1] -= p;
  AA[2] -= p;
  p = min(BB[2], AA[3]);
  bl += p;
  BB[2] -= p;
  AA[3] -= p;
  p = min(BB[3], AA[1]);
  bl += p;
  BB[3] -= p;
  AA[1] -= p;
  cout << an1 << " " << bl << endl;
}
