#include <bits/stdc++.h>
using namespace std;
struct Player {
  int place;
  int mrange;
  int trange;
  bool if_move;
  int lifting;
  int lifted;
  bool if_lift;
  bool if_throw;
  Player(int p = 0, int m = 0, int t = 0, bool im = false, int ing = -1,
         int ed = -1, bool il = false, bool it = false) {
    place = p;
    mrange = m;
    trange = t;
    if_move = im;
    lifting = ing;
    lifted = ed;
    if_lift = il;
    if_throw = it;
  }
};
Player players[3];
int line[111];
const int num = 3;
int ans = -1;
void dfs();
void move(int w, int dis);
void lift(int w, int dis);
void throww(int w, int dis);
void move(int w, int dis) {
  int old_place = players[w].place;
  int new_place = players[w].place + dis;
  if (dis != 0 && new_place > 0 && line[new_place] == -1 &&
      (line[new_place + 1] != -1 || line[new_place - 1] != -1 ||
       dis == players[w].mrange)) {
    if (new_place > ans) ans = new_place;
    line[new_place] = w;
    line[old_place] = -1;
    players[w].place = new_place;
    players[w].if_move = true;
    dfs();
    players[w].if_move = false;
    players[w].place = old_place;
    line[old_place] = w;
    line[new_place] = -1;
  }
}
void lift(int w, int dis) {
  int old_place = players[w].place;
  int new_place = players[w].place + dis;
  if (dis != 0 && new_place > 0 && line[new_place] != -1) {
    int li = line[new_place];
    line[new_place] = -1;
    players[w].lifting = li;
    players[li].lifted = w;
    players[li].place = old_place;
    players[w].if_lift = true;
    dfs();
    players[w].if_lift = false;
    players[li].place = new_place;
    players[w].lifting = -1;
    players[li].lifted = -1;
    line[new_place] = li;
  }
}
void throww(int w, int dis) {
  int old_place = players[w].place;
  int new_place = players[w].place + dis;
  if (dis != 0 && new_place > 0 && line[new_place] == -1 &&
      (line[new_place + 1] != -1 || line[new_place - 1] != -1 ||
       dis == players[w].trange)) {
    if (new_place > ans) ans = new_place;
    int li = players[w].lifting;
    line[new_place] = li;
    players[li].place = new_place;
    players[w].lifting = -1;
    players[li].lifted = -1;
    players[w].if_throw = true;
    int lii = players[li].lifting;
    if (lii != -1) {
      players[lii].place = new_place;
    }
    dfs();
    if (lii != -1) {
      players[lii].place = old_place;
    }
    players[w].if_throw = false;
    players[li].lifted = w;
    players[w].lifting = li;
    players[li].place = old_place;
    line[new_place] = -1;
  }
}
void dfs() {
  int lifting, lifted;
  for (int i = 0; i < num; ++i) {
    lifting = players[i].lifting;
    lifted = players[i].lifted;
    for (int j = -players[i].mrange; j <= players[i].mrange; ++j) {
      if (players[i].if_move) break;
      if (lifting != -1 || lifted != -1) break;
      move(i, j);
    }
    for (int j = -1; j <= 1; ++j) {
      if (players[i].if_lift) break;
      if (lifting != -1 || lifted != -1) break;
      lift(i, j);
    }
    for (int j = -players[i].trange; j <= players[i].trange; ++j) {
      if (players[i].if_throw) break;
      if (lifting == -1) break;
      if (lifted != -1) break;
      throww(i, j);
    }
  }
}
int main() {
  for (int i = 0; i < num; ++i) {
    cin >> players[i].place >> players[i].mrange >> players[i].trange;
  }
  memset(line, -1, sizeof(line));
  dfs();
  cout << ans << endl;
  return 0;
}
