#include <bits/stdc++.h>
bool vis[55][55][55][9][9];
int origp[5], m[5], t[5], ans;
void dfs(int *p, int x, int y) {
  if (vis[p[0]][p[1]][p[2]][x][y]) return;
  vis[p[0]][p[1]][p[2]][x][y] = true;
  int mn = 50, mx = 0;
  for (int i = 0; i < 3; i++) {
    if (p[i] >= 45) continue;
    mn = std::min(mn, p[i]);
    mx = std::max(mx, p[i]);
  }
  ans = std::max(ans, mx);
  for (int i = 0; i < 3; i++) {
    int arr[3] = {p[0], p[1], p[2]};
    if (p[i] >= 45) {
      int pos = p[i] - 45;
      if (p[pos] >= 45) continue;
      for (int j = p[pos] + t[pos]; j >= p[pos] - t[pos] && j > 0; j--) {
        if (j != p[0] && j != p[1] && j != p[2]) {
          arr[i] = j;
          dfs(arr, x, y);
        }
      }
    } else if (i + 45 != p[0] && i + 45 != p[1] && i + 45 != p[2]) {
      if (!(y & (1 << i))) {
        for (int j = 0; j < 3; j++) {
          if (((p[i] - p[j]) < 0 ? -(p[i] - p[j]) : (p[i] - p[j])) != 1)
            continue;
          arr[j] = i + 45;
          dfs(arr, x, y | (1 << i));
          arr[j] = p[j];
        }
      }
      if (!(x & (1 << i))) {
        for (int j = p[i] + m[i]; j >= p[i] - m[i] && j > 0; j--) {
          if (j != p[0] && j != p[1] && j != p[2]) {
            arr[i] = j;
            dfs(arr, x | (1 << i), y);
          }
        }
      }
    }
  }
}
int main() {
  for (int i = 0; i < 3; i++) scanf("%d%d%d", origp + i, m + i, t + i);
  dfs(origp, 0, 0);
  printf("%d\n", ans);
  return 0;
}
