#include <bits/stdc++.h>
using std::abs;
int x[4], m[4], t[4], lifting[4];
bool lifted[4], canmove[4], canlift[4];
inline bool av(int i, int c) {
  for (int j = (1); j <= (3); ++j)
    if (j != c && x[j] == i) return false;
  return true;
}
int ans = 0, cdep = 0;
inline void dfs() {
  for (int i = (1); i <= (3); ++i)
    if (x[i] > ans) ans = x[i];
  for (int i = (1); i <= (3); ++i)
    if (!lifted[i]) {
      if (canmove[i] && !lifting[i]) {
        int tar;
        for (int j = (1); j <= (3); ++j) {
          tar = x[j] - 1;
          if (abs(tar - x[i]) <= m[i] && av(tar, i)) {
            int tmp = x[i];
            x[i] = tar;
            canmove[i] = 0;
            dfs();
            x[i] = tmp;
            canmove[i] = 1;
          }
          tar = x[j] + 1;
          if (abs(tar - x[i]) <= m[i] && av(tar, i)) {
            int tmp = x[i];
            x[i] = tar;
            canmove[i] = 0;
            dfs();
            x[i] = tmp;
            canmove[i] = 1;
          }
        }
        tar = x[i] - m[i];
        if (av(tar, i)) {
          int tmp = x[i];
          x[i] = tar;
          canmove[i] = 0;
          dfs();
          x[i] = tmp;
          canmove[i] = 1;
        }
        tar = x[i] + m[i];
        if (av(tar, i)) {
          int tmp = x[i];
          x[i] = tar;
          canmove[i] = 0;
          dfs();
          x[i] = tmp;
          canmove[i] = 1;
        }
      }
      if (canlift[i])
        for (int j = (1); j <= (3); ++j)
          if (i != j && abs(x[i] - x[j]) == 1 && !lifted[j]) {
            int tmp = x[j];
            canlift[i] = 0;
            lifting[i] = j;
            lifted[j] = 1;
            x[j] = x[i];
            dfs();
            canlift[i] = 1;
            lifting[i] = 0;
            lifted[j] = 0;
            x[j] = tmp;
          }
      if (lifting[i]) {
        int tar;
        int j = 6 - i - lifting[i];
        tar = x[j] - 1;
        if (abs(tar - x[i]) <= t[i] && av(tar, i)) {
          int tmp = x[i], tmp2 = lifting[i];
          x[lifting[i]] = tar;
          lifted[lifting[i]] = 0;
          lifting[i] = 0;
          dfs();
          x[lifting[i]] = tmp;
          lifting[i] = tmp2;
          lifted[lifting[i]] = 1;
        }
        tar = x[j] + 1;
        if (abs(tar - x[i]) <= t[i] && av(tar, i)) {
          int tmp = x[i], tmp2 = lifting[i];
          x[lifting[i]] = tar;
          lifted[lifting[i]] = 0;
          lifting[i] = 0;
          dfs();
          x[lifting[i]] = tmp;
          lifting[i] = tmp2;
          lifted[lifting[i]] = 1;
        }
        tar = x[i] - t[i];
        if (x[j] != tar) {
          int tmp = x[i], tmp2 = lifting[i];
          x[lifting[i]] = tar;
          lifted[lifting[i]] = 0;
          lifting[i] = 0;
          dfs();
          x[lifting[i]] = tmp;
          lifting[i] = tmp2;
          lifted[lifting[i]] = 1;
        }
        tar = x[i] + t[i];
        if (x[j] != tar) {
          int tmp = x[i], tmp2 = lifting[i];
          x[lifting[i]] = tar;
          lifted[lifting[i]] = 0;
          lifting[i] = 0;
          dfs();
          x[lifting[i]] = tmp;
          lifting[i] = tmp2;
          lifted[lifting[i]] = 1;
        }
        tar = x[i] - 1;
        if (x[j] != tar) {
          int tmp = x[i], tmp2 = lifting[i];
          x[lifting[i]] = tar;
          lifted[lifting[i]] = 0;
          lifting[i] = 0;
          dfs();
          x[lifting[i]] = tmp;
          lifting[i] = tmp2;
          lifted[lifting[i]] = 1;
        }
        tar = x[i] + 1;
        if (x[j] != tar) {
          int tmp = x[i], tmp2 = lifting[i];
          x[lifting[i]] = tar;
          lifted[lifting[i]] = 0;
          lifting[i] = 0;
          dfs();
          x[lifting[i]] = tmp;
          lifting[i] = tmp2;
          lifted[lifting[i]] = 1;
        }
      }
    }
}
int main() {
  for (int i = (1); i <= (3); ++i) scanf("%d%d%d", x + i, m + i, t + i);
  memset(lifting, 0, sizeof(lifting));
  memset(lifted, 0, sizeof(lifted));
  memset(canmove, 1, sizeof(canmove));
  memset(canlift, 1, sizeof(canlift));
  dfs();
  printf("%d\n", ans);
  return 0;
}
