#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from;
  int to;
  int res_flow;
  int back_edge;
};
vector<pair<int, int> > adj[10001];
vector<int> residual[10001];
vector<edge> arr;
int n, m, c, u, v, source, sink;
int max_flow = 0;
bool bfs(vector<int>& parent) {
  vector<bool> vis(n + 1);
  queue<int> q;
  q.push(source);
  vis[source] = true;
  while (!q.empty()) {
    int temp = q.front();
    q.pop();
    for (auto ele : residual[temp])
      if (!vis[arr[ele].to] && arr[ele].res_flow > 0)
        vis[arr[ele].to] = true, q.push(arr[ele].to), parent[arr[ele].to] = ele;
    if (vis[sink]) return true;
  }
  return false;
}
int edmonds_karp() {
  int cc = 0;
  for (int node = 1; node <= n; node++)
    for (auto ele : adj[node])
      if (ele.second > 0)
        residual[node].push_back(cc),
            arr.push_back({node, ele.first, ele.second, cc + 1}),
            residual[ele.first].push_back(cc + 1),
            arr.push_back({ele.first, node, 0, cc}), cc += 2;
  vector<int> parent(n + 1);
  while (bfs(parent)) {
    int path_capacity = INT_MAX;
    for (int v2 = sink; v2 != source; v2 = arr[parent[v2]].from)
      path_capacity = min(path_capacity, arr[parent[v2]].res_flow);
    for (int v2 = sink; v2 != source; v2 = arr[parent[v2]].from) {
      arr[parent[v2]].res_flow -= path_capacity;
      arr[arr[parent[v2]].back_edge].res_flow += path_capacity;
    }
    max_flow += path_capacity;
  }
  return max_flow;
}
int main() {
  long long a1, a2, a3, b1, b2, b3, num;
  cin >> num;
  cin >> a1 >> a3 >> a2;
  cin >> b1 >> b3 >> b2;
  n = 8;
  source = 1, sink = 8;
  adj[1].push_back({2, a1}), adj[1].push_back({3, a2}),
      adj[1].push_back({4, a3});
  adj[2].push_back({5, INT_MAX}), adj[2].push_back({6, INT_MAX}),
      adj[3].push_back({6, INT_MAX}), adj[3].push_back({7, INT_MAX}),
      adj[4].push_back({5, INT_MAX}), adj[4].push_back({7, INT_MAX});
  adj[5].push_back({8, b1}), adj[6].push_back({8, b2}),
      adj[7].push_back({8, b3});
  long long minm, maxm;
  minm = num - edmonds_karp();
  maxm = min(a1, b3) + min(a2, b1) + min(a3, b2);
  cout << minm << " " << maxm << "\n";
}
