Solution to the balanced smileys problem.