When balls touch, they rotate by 180 degrees. This makes them move apart in the exact opposite direction they had when they collided.