John now has X - 3
and splits the remainder equally between himself and his brothers
Each of the brothers now has (X-3)/3 apples (we have to assume here that Jack and Jim didn't have any apples to begin with).
Jack and John both eat half of the apples they have been given
They now have (X-3)/3/2, or just (X-3)/6
Together the three brothers have 4 apples left
Now we say 4 = (X-3)/3 (Jim) + (X-3)/6 (Jack) + (X-3)/6 (John)
From here it's algebra. A nice trick we can do here is to add (X-3)/6 + (X-3)/6 together first, since they have the same denominator:
4 = (X-3)/3 + (X-3)/3
From there we can do the same trick, since now we have two terms that are both something/3:
4 = 2(X-3)/3
Multiply both sides by 3, divide both sides by 2:
6 = X - 3
Add 3 to both sides
9 = X