Simple trial and improvement - you do not need equations to solve this.