#include <bits/stdc++.h>
using namespace std;
long long fpm(long long b, long long e, long long m) {
  long long t = 1;
  for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;
  return t;
}
template <class T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class edge>
struct Graph {
  vector<vector<edge> > adj;
  Graph(int n) {
    adj.clear();
    adj.resize(n + 5);
  }
  Graph() { adj.clear(); }
  void resize(int n) { adj.resize(n + 5); }
  void add(int s, edge e) { adj[s].push_back(e); }
  void del(int s, edge e) {
    adj[s].erase(find((adj[s]).begin(), (adj[s]).end(), e));
  }
  int deg(int v) { return adj[v].size(); }
  vector<edge> &operator[](int t) { return adj[t]; }
};
const int MOVE = 1, LIFT = 2, THR = 4;
struct unit {
  int pos, todo, lifted, mv, thr;
};
unit S[4];
int ans = 0;
void dfs() {
  int dist = 0, add = 0;
  for (auto &x : S) {
    dist = max(dist, x.pos);
    if (x.todo & MOVE) add += x.mv;
    if (x.todo & THR) add += x.thr;
  }
  if (dist + add <= ans) return;
  for (int i = 0; i < 3; ++i) {
    unit &x = S[i];
    ans = max(ans, x.pos);
    if (ans == 42) return;
    if (x.lifted != -1) continue;
    if ((!(x.todo & THR) || (x.todo & LIFT)) && (x.todo & MOVE)) {
      x.todo ^= MOVE;
      for (int z = x.mv; z >= -x.mv; --z) {
        int t = z + x.pos;
        bool b = t > 0;
        for (int j = 0; j < 3; ++j)
          if (S[j].lifted == -1 && t == S[j].pos) b = false;
        if (b) {
          x.pos += z;
          dfs();
          x.pos -= z;
        }
      }
      x.todo ^= MOVE;
    }
    if (x.todo & LIFT) {
      x.todo ^= LIFT;
      int a = x.pos + 1, b = x.pos - 1;
      for (int j = 0; j < 3; ++j)
        if (S[j].lifted == -1 && (S[j].pos == a || S[j].pos == b)) {
          int bak = S[j].pos;
          S[j].lifted = i;
          dfs();
          S[j].lifted = -1;
          S[j].pos = bak;
        }
      x.todo ^= LIFT;
    }
    if (x.todo & THR) {
      x.todo ^= THR;
      int z = -1;
      for (int j = 0; j < 3; ++j)
        if (S[j].lifted == i) z = j;
      if (z != -1) {
        for (int j = x.thr; j >= -x.thr; --j) {
          int t = j + x.pos;
          bool b = t > 0;
          for (int r = 0; r < 3; ++r)
            if (S[r].lifted == -1 && t == S[r].pos) b = false;
          if (b) {
            S[z].pos = t, S[z].lifted = -1;
            dfs();
            S[z].lifted = i;
          }
        }
      }
      x.todo ^= THR;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  for (auto &x : S) {
    cin >> x.pos >> x.mv >> x.thr;
    x.todo = 7, x.lifted = -1;
  }
  dfs();
  cout << ans << endl;
  cerr << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  return 0;
}
