#include <bits/stdc++.h>
using namespace std;
int w[4];
int x[4];
int l[4];
int t[4];
int ans = 0;
int p[4];
int a[4];
bool near(int s) {
  for (int i = 1; i <= 3; i++)
    if (s == x[i] + 1 || s == x[i] - 1) return true;
  return false;
}
void dfs(int d) {
  for (int i = 1; i <= 3; i++) ans = max(ans, x[i]);
  for (int i = 1; i <= 3; i++) {
    if (w[i]) continue;
    if ((a[i] & 1) && !(a[i] & 4)) {
      for (int j = 1; j <= l[i]; j++) {
        x[i] += j;
        a[i] ^= 1;
        if (near(x[i]) || j == l[i]) dfs(d + 1);
        x[i] -= j;
        x[i] -= j;
        if (near(x[i]) || j == l[i]) dfs(d + 1);
        x[i] += j;
        a[i] ^= 1;
      }
    }
    if (a[i] & 2) {
      for (int j = 1; j <= 3; j++)
        if (i != j && !w[j] && t[i] > 0) {
          if (x[i] == x[j] + 1 || x[j] == x[i] + 1) {
            int e;
            w[j] = 1;
            a[i] ^= 2;
            a[i] ^= 4;
            p[i] = j;
            e = x[j];
            x[j] = -j;
            dfs(d + 1);
            x[j] = e;
            w[j] = 0;
            a[i] ^= 2;
            a[i] ^= 4;
          }
        }
    }
    if (a[i] & 4) {
      for (int j = 1; j <= t[i]; j++) {
        w[p[i]] = 0;
        a[i] ^= 4;
        int e;
        e = x[p[i]];
        x[p[i]] = x[i] + j;
        if (near(x[p[i]]) || j == t[i]) dfs(d + 1);
        x[p[i]] -= j * 2;
        if (near(x[p[i]]) || j == t[i]) dfs(d + 1);
        x[p[i]] = e;
        a[i] ^= 4;
        w[p[i]] = 1;
      }
    }
  }
}
int main() {
  for (int i = 1; i <= 3; i++) scanf("%d%d%d", &x[i], &l[i], &t[i]);
  a[1] = a[2] = a[3] = 3;
  dfs(1);
  printf("%d\n", ans);
  return 0;
}
