#include <bits/stdc++.h>
int p[3], m[3], t[3], ans, dep;
bool f[48][48][48][8][8];
void dfs(int *p, int x, int y) {
  bool &res = f[p[0]][p[1]][p[2]][x][y];
  if (res) return;
  res = 1;
  int far = 0, near = 50;
  for (int i = 0; i < 3; i++) {
    if (p[i] < 45 && p[i] > far) far = p[i];
    if (p[i] < near) near = p[i];
  }
  if (far > ans) ans = far;
  for (int j = 0; j < 3; j++) {
    int q[3] = {p[0], p[1], p[2]}, z = 1 << j;
    if (p[j] >= 45) {
      int T = p[j] - 45;
      for (int i = p[T] + t[T];
           p[T] < 45 && i >= p[T] - t[T] && i > near - 2 && i; i--)
        if (i - p[0] && i - p[1] && i - p[2]) q[j] = i, dfs(q, x, y);
    } else if (j + 45 - p[0] && j + 45 - p[1] && j + 45 - p[2]) {
      if (y & z)
        for (int i = 0; i < 3; i++)
          if (fabs(p[i] - p[j]) == 1)
            q[i] = 45 + j, dfs(q, x, y ^ z), q[i] = p[i];
      if (x & z)
        for (int i = p[j] + m[j]; i >= p[j] - m[j] && i > near - 2 && i; i--)
          if (i - p[0] && i - p[1] && i - p[2]) q[j] = i, dfs(q, x ^ z, y);
    }
  }
}
int main() {
  for (int i = 0; i < 3; i++) scanf("%d%d%d", p + i, m + i, t + i);
  dfs(p, 7, 7);
  printf("%d\n", ans);
  return 0;
}
