#include <bits/stdc++.h>
using namespace std;
int p[3], m[3], t[3], ans, cnt = 0;
bool moved[3], grabed[3];
int grab[3];
bool dp[45][45][45][2][2][2][5][5][5];
void dfs() {
  bool& now = dp[p[0]][p[1]][p[2]][moved[0]][moved[1]][moved[2]][grab[0] + 2]
                [grab[1] + 2][grab[2] + 2];
  if (now) return;
  now = true;
  ans = (ans < p[0] ? p[0] : ans);
  ans = (ans < p[1] ? p[1] : ans);
  ans = (ans < p[2] ? p[2] : ans);
  for (int i = 0; i < 3; i++) {
    if (!grabed[i] && (grab[i] == -1 || grab[i] == -2) && !moved[i]) {
      int pos = p[i];
      moved[i] = true;
      for (int j = max(1, pos - m[i]); j < pos + m[i] + 1; j++)
        if (j != pos) {
          p[i] = j;
          dfs();
        }
      p[i] = pos;
      moved[i] = false;
    }
  }
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) {
      if (i == j) continue;
      if (!grabed[i] && grab[i] == -1 && !grabed[j] && abs(p[i] - p[j]) == 1) {
        grab[i] = j;
        grabed[j] = true;
        int pos = p[j];
        p[j] = p[i];
        dfs();
        grab[i] = -1;
        grabed[j] = false;
        p[j] = pos;
      }
    }
  for (int i = 0; i < 3; i++) {
    if (grab[i] != -1 && grab[i] != -2) {
      int j = grab[i];
      grab[i] = -2;
      grabed[j] = false;
      for (int k = max(i, p[i] - t[i]); k < p[i] + t[i] + 1; k++) {
        p[j] = k;
        dfs();
      }
      grab[i] = j;
      grabed[j] = true;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < 3; i++) {
    cin >> p[i] >> m[i] >> t[i];
    grab[i] = -1;
  }
  dfs();
  cout << ans;
}
