using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
//using DebugerVisualizer;

namespace _105
{
	[Serializable]
	class VNodeValue<TNode>
	{
		public int Version;
		public TNode Value;

		public VNodeValue(int version)
		{
			Version = version;
		}
	}

	[Serializable]
	class VEdge<TNode, TEdge>
		where TNode : ICloneable
	{
		public TEdge Value;
		public VNode<TNode, TEdge> Source;
		public VNode<TNode, TEdge> Target;

		public override string ToString()
		{
			return Value.ToString();
		}
	}

	[Serializable]
	class VEdges<TNode, TEdge>
		where TNode : ICloneable
	{
		public int Version;
		public List<VEdge<TNode, TEdge>> Edges = new List<VEdge<TNode, TEdge>>();

		public VEdges(int version)
		{
			Version = version;
		}
	}

	[Serializable]
	class VNode<TNode, TEdge>
		where TNode : ICloneable
	{
		VGraph<TNode, TEdge> _graph;

		Stack<VNodeValue<TNode>> _valueStack = new Stack<VNodeValue<TNode>>();
		Stack<VEdges<TNode, TEdge>> _ins = new Stack<VEdges<TNode, TEdge>>();
		Stack<VEdges<TNode, TEdge>> _outs = new Stack<VEdges<TNode, TEdge>>();

		internal VNode(VGraph<TNode, TEdge> graph, TNode nodeValue)
		{
			_graph = graph;
			var newNode = new VNodeValue<TNode>(_graph.Version);
			newNode.Value = nodeValue;
			_valueStack.Push(newNode);
			_ins.Push(new VEdges<TNode, TEdge>(_graph.Version));
			_outs.Push(new VEdges<TNode, TEdge>(_graph.Version));
		}

		public TNode ReadValue
		{
			get { return _valueStack.Peek().Value; }
		}

		public TNode WriteValue
		{
			get
			{
				if (_valueStack.Peek().Version != _graph.Version)
				{
					var newVersion = new VNodeValue<TNode>(_graph.Version);
					if (_valueStack.Peek().Value != null)
						newVersion.Value = (TNode)_valueStack.Peek().Value.Clone();
					_valueStack.Push(newVersion);
					_graph.SheduleValueRollback(this);
				}

				return _valueStack.Peek().Value;
			}
		}

		public IEnumerable<VEdge<TNode, TEdge>> Ins
		{
			get
			{
				foreach (var edges in _ins)
					foreach (var e in edges.Edges)
					{
						yield return e;
					}
			}
		}

		public IEnumerable<VEdge<TNode, TEdge>> Outs
		{
			get
			{
				foreach (var edges in _outs)
					foreach (var e in edges.Edges)
					{
						yield return e;
					}
			}
		}

		public void AddIns(VEdge<TNode, TEdge> edge)
		{
			if (_ins.Peek().Version != _graph.Version)
			{
				var newVersion = new VEdges<TNode, TEdge>(_graph.Version);
				_ins.Push(newVersion);
				_graph.SheduleInEdgeRollback(this);
			}
			_ins.Peek().Edges.Add(edge);
		}

		public void AddOut(VEdge<TNode, TEdge> edge)
		{
			if (_outs.Peek().Version != _graph.Version)
			{
				var newVersion = new VEdges<TNode, TEdge>(_graph.Version);
				_outs.Push(newVersion);
				_graph.SheduleOutEdgeRollback(this);
			}
			_outs.Peek().Edges.Add(edge);
		}

		internal void RollbackValue()
		{
			_valueStack.Pop();
		}

		internal void RollbackIns()
		{
			_ins.Pop();
		}

		internal void RollbackOuts()
		{
			_outs.Pop();
		}

		public override string ToString()
		{
			return ReadValue.ToString();
		}
	}

	[Serializable]
	class VGraph<TNode, TEdge> : IDisposable
		where TNode : ICloneable
	{
		public int Version = 0;

		Stack<List<VNode<TNode, TEdge>>> _valueRollbacks = new Stack<List<VNode<TNode, TEdge>>>();
		Stack<List<VNode<TNode, TEdge>>> _inEdgeRollbacks = new Stack<List<VNode<TNode, TEdge>>>();
		Stack<List<VNode<TNode, TEdge>>> _outEdgeRollbacks = new Stack<List<VNode<TNode, TEdge>>>();

		public VGraph()
		{
			StartTransaction();
		}

		public void SheduleValueRollback(VNode<TNode, TEdge> node)
		{
			_valueRollbacks.Peek().Add(node);
		}

		public void SheduleInEdgeRollback(VNode<TNode, TEdge> node)
		{
			_inEdgeRollbacks.Peek().Add(node);
		}

		public void SheduleOutEdgeRollback(VNode<TNode, TEdge> node)
		{
			_outEdgeRollbacks.Peek().Add(node);
		}

		public VNode<TNode, TEdge> AddNode(TNode nodeValue)
		{
			return new VNode<TNode, TEdge>(this, nodeValue);
		}

		public void AddEdge(VNode<TNode, TEdge> a, VNode<TNode, TEdge> b, TEdge edgeValue)
		{
			var newEdge = new VEdge<TNode, TEdge>();
			newEdge.Source = a;
			newEdge.Target = b;
			newEdge.Value = edgeValue;

			a.AddOut(newEdge);
			b.AddIns(newEdge);
		}

		public VGraph<TNode, TEdge> StartTransaction()
		{
			this.Version++;
			_valueRollbacks.Push(new List<VNode<TNode, TEdge>>());
			_inEdgeRollbacks.Push(new List<VNode<TNode, TEdge>>());
			_outEdgeRollbacks.Push(new List<VNode<TNode, TEdge>>());
			return this;
		}

		public void Rollback()
		{
			foreach (var values in _valueRollbacks.Pop())
				values.RollbackValue();
			foreach (var values in _inEdgeRollbacks.Pop())
				values.RollbackIns();
			foreach (var values in _outEdgeRollbacks.Pop())
				values.RollbackOuts();
			this.Version--;
		}

		public void Dispose()
		{
			Rollback();
		}
	}

	//[DebuggerVisualizer(typeof(ExpressionBuilderVisualizer))]
	[Serializable]
	class GameState : IDisposable
	{
		VGraph<ExpressionNode, ExpressionPath> _graph = new VGraph<ExpressionNode, ExpressionPath>();
		Stack<List<VNode<ExpressionNode, ExpressionPath>>> nodes = new Stack<List<VNode<ExpressionNode, ExpressionPath>>>();
		Stack<VNode<ExpressionNode, ExpressionPath>[]> playerNodes = new Stack<VNode<ExpressionNode, ExpressionPath>[]>();
		VNode<ExpressionNode, ExpressionPath>[] playerStartNodes = new VNode<ExpressionNode, ExpressionPath>[3];
		int nodesCount = 0;

		public IEnumerable<VNode<ExpressionNode, ExpressionPath>> Nodes
		{
			get
			{
				foreach (var ns in nodes)
					foreach (var node in ns)
						yield return node;
			}
		}

		public void ClearTrace(Player[] players)
		{
			foreach (var node in Nodes)
			{
				node.WriteValue.Min = int.MinValue/2;
				node.WriteValue.Max = int.MaxValue/2;
			}

			for (int i = 0; i < 3; i++)
			{
				playerStartNodes[i].WriteValue.Min = playerStartNodes[i].WriteValue.Max = players[i].Start;
			}
		}

		public GameState(Player[] players)
		{
			nodes.Push(new List<VNode<ExpressionNode, ExpressionPath>>());

			playerNodes.Push(new VNode<ExpressionNode, ExpressionPath>[3]);
			for (int i = 0; i < 3; i++)
			{
				var node = _graph.AddNode(new ExpressionNode() { Id = i, Min = players[i].Start, Max = players[i].Start, Comment = "S("+ i.ToString() +")" });
				nodes.Peek().Add(node);
				playerStartNodes[i] = node;
				playerNodes.Peek()[i] = node;
			}
			nodesCount = 3;
		}

		public GameState StartTransaction()
		{
			_graph.StartTransaction();
			nodes.Push(new List<VNode<ExpressionNode, ExpressionPath>>());
			playerNodes.Push( (VNode<ExpressionNode, ExpressionPath>[])playerNodes.Peek().Clone());
			return this;
		}

		public void Dispose()
		{
			_graph.Rollback();

			nodesCount -= nodes.Pop().Count;
			playerNodes.Pop();
		}

		public int Max
		{
			get
			{
				int max = Int32.MinValue;
				foreach (var node in Nodes)
				{
					if (max < node.ReadValue.Max)
						max = node.ReadValue.Max;
				}

				return max;
			}
		}

		public VNode<ExpressionNode, ExpressionPath> AddPlayerNode(int i, string comment)
		{
			var nodeValue = new ExpressionNode() { Id = nodesCount++ };
			nodeValue.Comment = comment;
			var node = _graph.AddNode(nodeValue);
			nodes.Peek().Add(node);
			playerNodes.Peek()[i] = node;
			return node;
		}

		public VNode<ExpressionNode, ExpressionPath> GetPlayerNode(int i)
		{
			return playerNodes.Peek()[i];
		}

		public VNode<ExpressionNode, ExpressionPath> GetPlayerStartNode(int i)
		{
			return playerStartNodes[i];
		}

		//a <= b + c
		public bool AddMin(VNode<ExpressionNode, ExpressionPath> a, VNode<ExpressionNode, ExpressionPath> b, int c)
		{
			var path = new ExpressionPath() { Mark = c };
			_graph.AddEdge(b, a, path);

			if (a.ReadValue.Max > b.ReadValue.Max + c)
				a.WriteValue.Max = b.ReadValue.Max + c;

			if (b.ReadValue.Min < a.ReadValue.Min - c)
				b.WriteValue.Min = a.ReadValue.Min - c;

			if (!Trace(a))
				return false;
			if (!Trace(b))
				return false;
			if (!Validate())
				return false;

			return true;
		}

		bool Trace(VNode<ExpressionNode, ExpressionPath> a)
		{
			if (!TraceMin(this, a))
				return false;
			if (!TraceMax(this, a))
				return  false;
			return true;
		}

		static bool TraceMin(GameState state, VNode<ExpressionNode, ExpressionPath> x)
		{
			x.WriteValue.Traced = true;

			try
			{
				foreach (var vector in state.Maximize(x))
				{
					// x <= path.Max + path.Mark

					if (vector.Target.ReadValue.Traced)
					{
						if (vector.Target.ReadValue.Min < x.ReadValue.Min - vector.Mark)
							return false;
					}
					else
					{
						if (vector.Target.ReadValue.Min < x.ReadValue.Min - vector.Mark)
						{
							vector.Target.WriteValue.Min = x.ReadValue.Min - vector.Mark;
							if (!TraceMin(state, vector.Target))
								return false;
						}
					}
				}
				return true;
			}
			finally
			{
				x.WriteValue.Traced = false;
			}
		}

		static bool TraceMax(GameState state, VNode<ExpressionNode, ExpressionPath> x)
		{
			x.WriteValue.Traced = true;

			try
			{
				foreach (var vector in state.Minimize(x))
				{
					if (vector.Target.ReadValue.Traced)
					{
						if (vector.Target.ReadValue.Max > x.ReadValue.Max + vector.Mark)
							return false;
					}
					else
					{
						if (vector.Target.ReadValue.Max > x.ReadValue.Max + vector.Mark)
						{
							vector.Target.WriteValue.Max = x.ReadValue.Max + vector.Mark;
							if (!TraceMax(state, vector.Target))
								return false;
						}
					}
				}
				return true;
			}
			finally
			{
				x.WriteValue.Traced = false;
			}
		}

		public IEnumerable<Vector> Maximize(VNode<ExpressionNode, ExpressionPath> a)
		{
			return a.Ins.Select(path => new Vector(path.Value.Mark, path.Source));
		}

		public IEnumerable<Vector> Minimize(VNode<ExpressionNode, ExpressionPath> a)
		{
			return a.Outs.Select(path => new Vector(path.Value.Mark, path.Target));
		}

		public bool Validate()
		{
			foreach (var node in Nodes)
			{
				if (node.ReadValue.Min > node.ReadValue.Max)
					return false;
			}

			return true;
		}

		public override string ToString()
		{
			string result = "";

			foreach (var node in Nodes.Reverse())
			{
				result += node.ReadValue.ToString();
			}

			return result;
		}
	}

	[Serializable]
	struct Vector
	{
		public int Mark;
		public VNode<ExpressionNode, ExpressionPath> Target;

		public Vector(int mark, VNode<ExpressionNode, ExpressionPath> target)
		{
			Mark = mark;
			Target = target;
		}
	}

	[Serializable]
	internal class Player
	{
		public int Start;
		public int Walk;
		public int Throws;

		public bool alreadyWalked = false;
		public bool alreadyUpped = false;
		public bool alreadyThrowed = false;
		public bool Upped = false;
		public int Up = -1;
	}

	[Serializable]
	class ExpressionNode : ICloneable
	{
		public int Id;
		public int Min = int.MinValue/2;
		public int Max = int.MaxValue/2;
		public bool Traced = false;
		public string Comment;

		public object Clone()
		{
			return this.MemberwiseClone();
		}

		public override string ToString()
		{
			return Comment + String.Format("[{0}:{1}]", Min, Max);
		}

	}

	[Serializable]
	[ReadOnly(true)]
	struct ExpressionPath
	{
		public int Mark;

		public override string ToString()
		{
			var result = String.Format("({0})", Mark);
			return result;
		}
	}

	class Program
	{
		//static StreamReader inStream = new StreamReader("input.txt");
		//static string ReadLine()
		//{
		//    return inStream.ReadLine();
		//}

		static string ReadLine()
		{
			return Console.ReadLine();
		}

		static int AbsoluteMax = int.MinValue;
		static string AbsoluteMaxStr = "";

		static void Main(string[] args)
		{
			Player[] players = new Player[3];
			for (int i = 0; i < 3; i++)
			{
				players[i] = new Player();
				string[] arg = ReadLine().Split();
				players[i].Start = int.Parse(arg[0]);
				players[i].Walk = int.Parse(arg[1]);
				players[i].Throws = int.Parse(arg[2]);
			}

			var state = new GameState(players);

			Solve(state, players);
			Console.WriteLine(AbsoluteMax);
			//Console.WriteLine(AbsoluteMaxStr);
		}

		static void Solve(GameState state, Player[] players)
		{
			if (EuristicGetMax(state, players) <= AbsoluteMax)
				return;

			int max = state.Max;
			if (AbsoluteMax < max)
			{
				AbsoluteMax = max;
				AbsoluteMaxStr = state.ToString();
			}

			for (int i = 0; i < 3; i++)
			{
				using (var clone = state.StartTransaction())
				{
					DoMove(i, clone, players);
				}
			}

			for (int i = 0; i < 3; i++)
				for (int j = 0; j < 3; j++)
					if (i != j)
					{
						using (var clone = state.StartTransaction())
						{
							DoUp(i, j, clone, players);
						}
					}

			for (int i = 0; i < 3; i++)
			{
				using (var clone = state.StartTransaction())
				{
					DoThrow(i, clone, players);
				}
			}
		}

		static private void DoMove(int i, GameState state, Player[] players)
		{
			if (players[i].alreadyWalked || players[i].Up >= 0 || players[i].Upped)
				return;

			players[i].alreadyWalked = true;

			VNode<ExpressionNode, ExpressionPath> a = state.GetPlayerNode(i);
			VNode<ExpressionNode, ExpressionPath> moved = state.AddPlayerNode(i, string.Format("M({0})", i));

			if (!state.AddMin(moved, a, players[i].Walk))
				return;
			if (!state.AddMin(a, moved, players[i].Walk))
				return;

			using (var clone = state.StartTransaction())
			{
				NotEqual(players, i, clone);
			}

			players[i].alreadyWalked = false;
		}

		private static void DoThrow(int i, GameState state, Player[] players)
		{
			if (players[i].alreadyThrowed || players[i].Up < 0 || players[i].Upped)
				return;

			players[i].alreadyThrowed = true;

			int j = players[i].Up;
			players[i].Up = -1;
			players[j].Upped = false;

			VNode<ExpressionNode, ExpressionPath> a = state.GetPlayerNode(i);
			VNode<ExpressionNode, ExpressionPath> moved = state.AddPlayerNode(j, string.Format("T({0}, {1})", i, j));

			if (!state.AddMin(moved, a, players[i].Throws))
				return;
			if (!state.AddMin(a, moved, players[i].Throws))
				return;

			NotEqual(players, j, state);

			players[j].Upped = true;
			players[i].Up = j;
			players[i].alreadyThrowed = false;
		}

		private static void DoUp(int i, int j, GameState state, Player[] players)
		{
			if (players[i].alreadyUpped || players[i].Up >= 0 || players[i].Upped || players[j].Upped || i == j)
				return;

			players[i].alreadyUpped = true;
			players[i].Up = j;
			players[j].Upped = true;

			VNode<ExpressionNode, ExpressionPath> a = state.GetPlayerNode(i);
			VNode<ExpressionNode, ExpressionPath> b = state.GetPlayerNode(j);

			VNode<ExpressionNode, ExpressionPath> moved = state.AddPlayerNode(j, string.Format("U({0}, {1})", i, j));

			if (!state.AddMin(moved, a, 0))
				return;
			if (!state.AddMin(a, moved, 0))
				return;

			Equal(state, players, a, b, 1);
			Equal(state, players, a, b, -1);

			players[j].Upped = false;
			players[i].Up = -1;
			players[i].alreadyUpped = false;
		}

		//a = b + c
		private static void Equal(GameState state, Player[] players, VNode<ExpressionNode, ExpressionPath> a, VNode<ExpressionNode, ExpressionPath> b, int c)
		{
			using (var v1 = state.StartTransaction())
			{
				if (v1.AddMin(b, a, -c) && v1.AddMin(a, b, c))
					Solve(v1, players);
			}
		}

		static private void NotEqual(Player[] players, int i, GameState state)
		{
			VNode<ExpressionNode, ExpressionPath> a = state.GetPlayerNode(i); //current
			VNode<ExpressionNode, ExpressionPath> b = state.GetPlayerNode((i + 1) % 3); //not equal to
			VNode<ExpressionNode, ExpressionPath> c = state.GetPlayerNode((i + 2) % 3); //and not equal to

			using (var v1 = state.StartTransaction())
			{
				if (v1.AddMin(a, b, -1) && v1.AddMin(a, c, -1))
					Solve(v1, players);
			}

			using (var v2 = state.StartTransaction())
			{
				if (v2.AddMin(b, a, -1) && v2.AddMin(a, c, -1))
					Solve(v2, players);
			}

			using (var v3 = state.StartTransaction())
			{
				if (v3.AddMin(b, a, -1) && v3.AddMin(c, a, -1))
					Solve(v3, players);
			}

			using (var v4 = state.StartTransaction())
			{
				if (v4.AddMin(a, b, -1) && v4.AddMin(c, a, -1))
					Solve(v4, players);
			}
		}

		static int EuristicGetMax(GameState state, Player[] players)
		{
			int radius = 0;

			for (int i = 0; i < 3; i++)
			{
				if (!players[i].alreadyThrowed)
					radius += players[i].Throws;
				if (!players[i].alreadyWalked)
					radius += players[i].Walk;
				if (!players[i].alreadyUpped)
					radius += 1;
			}

			var result = Enumerable.Range(0,3).Max(i => state.GetPlayerNode(i).ReadValue.Max + radius);
			return result;
		}
	}

}