Implemented quadratic time triangle counter.