#include <bits/stdc++.h>
using namespace std;
template <class T>
T Push(T x) {
  cin >> x;
  return x;
}
int sol(vector<int> Win, vector<int> Lose, int n) {
  int res = 0;
  for (int i = 0; i < 3; i++) {
    if (Win[i] != 0 && Lose[(i + 1) % 3] != 0)
      res += min(Win[i], Lose[(i + 1) % 3]);
  }
  return res;
}
bool cmp(pair<int, int> &a, pair<int, int> &b) { return a.first > b.first; }
int sol2(vector<int> Win, vector<int> Lose, int n, vector<int> brut) {
  for (auto i : brut) {
    if (Win[i] != 0 && Lose[(i + 2) % 3] != 0) {
      int aux = min(Win[i], Lose[(i + 2) % 3]);
      Lose[(i + 2) % 3] -= aux;
      Win[i] -= aux;
    }
    if (Win[i] != 0 && Lose[i] != 0) {
      int aux = min(Win[i], Lose[i]);
      Lose[i] -= aux;
      Win[i] -= aux;
    }
  }
  return Win[0] + Win[1] + Win[2];
}
int main() {
  int n;
  cin >> n;
  vector<int> Win, Lose;
  int aux;
  for (int i = 0; i < 3; i++) {
    Win.push_back(Push(aux));
  }
  for (int i = 0; i < 3; i++) {
    Lose.push_back(Push(aux));
  }
  int res = n + 1;
  vector<int> brut(3);
  brut = {0, 1, 2};
  res = min(res, sol2(Win, Lose, n, brut));
  brut = {0, 2, 1};
  res = min(res, sol2(Win, Lose, n, brut));
  brut = {1, 0, 2};
  res = min(res, sol2(Win, Lose, n, brut));
  brut = {1, 2, 0};
  res = min(res, sol2(Win, Lose, n, brut));
  brut = {2, 1, 0};
  res = min(res, sol2(Win, Lose, n, brut));
  brut = {2, 0, 1};
  res = min(res, sol2(Win, Lose, n, brut));
  cout << res;
  cout << " " << sol(Win, Lose, n) << endl;
}
