The total amount of qualified tuition and related expenses shall be reduced by the amount of such expenses taken into account in determining any amount excluded under section
135,
529
(c)(1), or
530
(d)(2). For purposes of the preceding sentence, the amount taken into account in determining the amount excluded under section
529
(c)(1) shall not include that portion of the distribution which represents a return of any contributions to the plan.