#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int inf = 1e9 + 7;
const double eps = 1e-8;
long long qpow(long long a, long long b, long long m) {
  long long r = 1;
  a %= m;
  for (; b; b >>= 1) {
    if (b & 1) r = r * a % m;
    a = a * a % m;
  }
  return (r + m) % m;
}
const int maxn = 45;
int vis[55][55][55][4][4][4];
int a[4][4];
int ans = 0;
int dfs(int x1, int x2, int x3, int A, int B, int C) {
  if (vis[x1][x2][x3][A][B][C]) return 0;
  vis[x1][x2][x3][A][B][C] = 1;
  int b[4] = {0, x1, x2, x3};
  int c[4] = {0, A, B, C};
  int g[50] = {0};
  for (int i = 1; i <= 3; i++) g[b[i]] = i;
  for (int i = 1; i <= 3; i++) {
    int t = b[i];
    if (t <= maxn) {
      ans = max(ans, t);
      if (!(c[i] & 1) && !g[maxn + i]) {
        for (int j = max(0, t - a[i][2]); j <= t + a[i][2]; j++) {
          if (j > 0 && !g[j]) {
            b[i] = j;
            c[i] ^= 1;
            dfs(b[1], b[2], b[3], c[1], c[2], c[3]);
            b[i] = t;
            c[i] ^= 1;
          }
        }
      }
      if (!(c[i] & 2) && !g[maxn + i]) {
        for (int j = 1; j <= 3; j++) {
          int v = b[j];
          if (abs(t - v) != 1) continue;
          b[j] = maxn + i;
          c[i] ^= 2;
          dfs(b[1], b[2], b[3], c[1], c[2], c[3]);
          b[j] = v;
          c[i] ^= 2;
        }
      }
      if (g[maxn + i]) {
        int k = g[maxn + i];
        for (int j = max(0, t - a[i][3]); j <= t + a[i][3]; j++) {
          if (j > 0 && !g[j]) {
            b[k] = j;
            dfs(b[1], b[2], b[3], c[1], c[2], c[3]);
            b[k] = maxn + i;
          }
        }
      }
    }
  }
  return 0;
}
int main() {
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= 3; j++) cin >> a[i][j];
  dfs(a[1][1], a[2][1], a[3][1], 0, 0, 0);
  cout << ans << '\n';
  return 0;
}
