Union citizens and United Kingdom nationals, and their respective family members, who before the end of the transition period resided legally in the host State in accordance with the conditions of Article 7 of Directive 2004/38/EC for a period of less than 5 years, shall have the right to acquire the right to reside permanently under the conditions set out in Article 15 of this Agreement once they have completed the necessary periods of residence. Periods of legal residence or work in accordance with Union law before and after the end of the transition period shall be included in the calculation of the qualifying period necessary for acquisition of the right of permanent residence.