#include <bits/stdc++.h>
using namespace std;
int n, a1, a2, a3, b1, b2, b3;
int main() {
  cin >> n;
  cin >> a1 >> a2 >> a3 >> b1 >> b2 >> b3;
  int ans1 = n - (min(a1, b1 + b3) + min(a2, b2 + b1) + min(a3, b3 + b2));
  int ans2 = min(a1, b2) + min(a2, b3) + min(a3, b1);
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
