#include <bits/stdc++.h>
using namespace std;
int ans = INT_MAX, chck = 0;
void rec(int a[3], int b[3]) {
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (a[i] != 0) {
      cnt++;
      int j = (i + 2) % 3;
      if (b[i] != 0) {
        int val = min(b[i], a[i]);
        b[i] -= val;
        a[i] -= val;
        rec(a, b);
        a[i] += val;
        b[i] += val;
      } else if (b[j] != 0) {
        int val = min(b[j], a[i]);
        b[j] -= val;
        a[i] -= val;
        rec(a, b);
        a[i] += val;
        b[j] += val;
      } else {
        ans = min(ans, a[i]);
      }
    }
  }
  chck += (!cnt);
}
int main() {
  int n, i, j, k, l;
  cin >> n;
  int a[3], b[3];
  for (int i = 0; i < 3; i++) cin >> a[i];
  for (int j = 0; j < 3; j++) cin >> b[j];
  int maxi = 0;
  for (int i = 0; i < 3; i++) maxi += min(b[(i + 1) % 3], a[i]);
  rec(a, b);
  cout << ((chck || ans == INT_MAX) ? 0 : ans) << " " << maxi << endl;
  return 0;
}
