#include <bits/stdc++.h>
using namespace std;
struct PERSON {
  int pos, dis, thr, cat;
  bool moved, caught, thrown, becaught;
} a[4];
int ans = 0;
int LEA;
inline int Abs(int x) {
  if (x > 0) return x;
  return -x;
}
map<unsigned int, bool> u;
bool used() {
  int h[4];
  for (int i = 1; i <= 3; i++)
    h[i] =
        (((((a[i].pos * 4 + a[i].cat) * 2 + a[i].moved) * 2 + a[i].caught) * 2 +
          a[i].thrown) *
             2 +
         a[i].becaught);
  unsigned int x = h[1] * 10000000 + h[2] * 3200 + h[3];
  if (u.count(x)) return true;
  u[x] = true;
  return false;
}
void dfs() {
  if (used()) return;
  for (int i = 1; i <= 3; i++)
    if (a[i].pos > ans) ans = a[i].pos;
  for (int i = 1; i <= 3; i++)
    if (!a[i].becaught) {
      if (!a[i].moved && a[i].caught == a[i].thrown) {
        for (int j = a[i].pos - a[i].dis; j <= a[i].pos + a[i].dis; j++)
          if (j > LEA && j != a[1].pos && j != a[2].pos && j != a[3].pos) {
            a[i].moved = true;
            int t = a[i].pos;
            a[i].pos = j;
            dfs();
            a[i].moved = false;
            a[i].pos = t;
          }
      }
      if (!a[i].caught) {
        for (int j = 1; j <= 3; j++)
          if (j != i && Abs(a[i].pos - a[j].pos) == 1 && !a[j].becaught) {
            a[i].caught = true;
            a[j].becaught = true;
            a[i].cat = j;
            int t = a[j].pos;
            a[j].pos = a[i].pos;
            dfs();
            a[i].caught = false;
            a[j].becaught = false;
            a[j].pos = t;
          }
      } else if (!a[i].thrown) {
        for (int j = a[i].pos - a[i].thr; j <= a[i].pos + a[i].thr; j++)
          if (j > LEA && j != a[1].pos && j != a[2].pos && j != a[3].pos) {
            a[i].thrown = true;
            a[a[i].cat].becaught = false;
            int t = a[a[i].cat].pos;
            a[a[i].cat].pos = j;
            dfs();
            a[i].thrown = false;
            a[a[i].cat].becaught = true;
            a[a[i].cat].pos = t;
          }
      }
    }
}
int main() {
  for (int i = 1; i <= 3; i++) cin >> a[i].pos >> a[i].dis >> a[i].thr;
  if (a[1].pos > a[2].pos) swap(a[1], a[2]);
  if (a[1].pos > a[3].pos) swap(a[1], a[3]);
  LEA = a[1].pos;
  dfs();
  cout << ans << endl;
  return 0;
}
