#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, a2, b2, c2, minans, maxans;
int main() {
  cin >> n;
  cin >> a >> b >> c;
  cin >> a2 >> b2 >> c2;
  cout << n - min(a, c2 + a2) - min(b, b2 + a2) - min(c, b2 + c2) << " "
       << min(a, b2) + min(b, c2) + min(c, a2);
}
