#include <bits/stdc++.h>
using namespace std;
const long long INF = 63;
const int mxn = 2e5 + 5;
bool DEBUG = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  array<int, 3> a, b;
  cin >> n;
  cin >> a[0] >> a[1] >> a[2];
  cin >> b[0] >> b[1] >> b[2];
  int mx = min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0]);
  int mn = max(0, max({a[0] + b[1], a[1] + b[2], a[2] + b[0]}) - n);
  cout << mn << " " << mx << "\n";
}
