#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int len1[3], len2[3];
char table[50][50][50][512];
inline int sset(int x, int p, int len, int b) {
  int low = x & ((1 << p) - 1);
  x >>= (p + len);
  x <<= len;
  x += b;
  x <<= p;
  x += low;
  return x;
}
char getans(int p1, int p2, int p3, int mask) {
  char &ans = table[p1][p2][p3][mask];
  if (ans != -1) return ans;
  ans = max(p3, max(p1, p2));
  int p[3];
  p[0] = p1;
  p[1] = p2;
  p[2] = p3;
  int mm[3];
  int h[3], l[3];
  int up[3];
  int down[3];
  memset(down, -1, sizeof(down));
  for (int i = 0; i < (3); i++) {
    mm[i] = (mask >> (3 * i)) & 7;
    l[i] = mm[i] & 1;
    h[i] = mm[i] >> 1;
    if (h[i] == 0 || h[i] == 3)
      up[i] = -1;
    else
      up[i] = (i + h[i]) % 3;
  }
  for (int i = 0; i < (3); i++) {
    if (up[i] != -1) down[up[i]] = i;
  }
  for (int i = 0; i < (3); i++) {
    if (l[i] == 0 && up[i] == -1 && down[i] == -1) {
      for (int d = -len1[i]; d <= len1[i]; d++) {
        int nc = p[i] + d;
        if (nc >= 0 && nc != p1 && nc != p2 && nc != p3) {
          p[i] += d;
          ans = max(ans, getans(p[0], p[1], p[2], mask + (1 << (3 * i))));
          p[i] -= d;
        }
      }
    }
    if (h[i] == 0 && down[i] == -1) {
      for (int k = 0; k < (2); k++) {
        int o = (i + k + 1) % 3;
        if (abs(p[o] - p[i]) == 1) {
          int sp = p[o];
          p[o] = p[i];
          ans = max(ans,
                    getans(p[0], p[1], p[2], sset(mask, 3 * i + 1, 2, k + 1)));
          p[o] = sp;
        }
      }
    }
    if (up[i] != -1 && down[i] == -1) {
      int o = up[i];
      for (int d = -len2[i]; d <= len2[i]; d++) {
        int nc = p[i] + d;
        if (nc >= 0 && nc != p1 && nc != p2 && nc != p3) {
          if (up[o] == -1) {
            p[o] = nc;
            ans =
                max(ans, getans(p[0], p[1], p[2], sset(mask, 3 * i + 1, 2, 3)));
            p[o] = p[i];
          } else {
            int oo = up[o];
            p[oo] = p[o] = nc;
            ans =
                max(ans, getans(p[0], p[1], p[2], sset(mask, 3 * i + 1, 2, 3)));
            p[oo] = p[o] = p[i];
          }
        }
      }
    }
  }
  return ans;
}
int main() {
  int pos[3];
  for (int i = 0; i < (3); i++) {
    cin >> pos[i] >> len1[i] >> len2[i];
    pos[i]++;
  }
  memset(table, -1, sizeof(table));
  cout << getans(pos[0], pos[1], pos[2], 0) - 1 << endl;
  return 0;
}
