#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
const long INF = LONG_LONG_MAX, MOD = 1e9 + 7;
using namespace std;
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long extgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    int g = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
long long modpow(long long a, long long b) {
  long long res = 1;
  a %= MOD;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
void solve() {
  long long r, ar, ap, as, br, bp, bs;
  cin >> r >> ar >> as >> ap >> br >> bs >> bp;
  long long mx = min(r, min(ar, bs) + min(as, bp) + min(ap, br)), mn;
  mn = max(0LL, ap - (bp + bs)) + max(0LL, as - (bs + br)) +
       max(0LL, ar - (br + bp));
  mn = min(mn, r);
  cout << mn << ' ' << mx;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  { solve(); }
  return 0;
}
