FamilyMart Co. has agreed to buy Uny Group Holdings Co., the operator of the Circle K and Sunkus chains, creating the nation's second-largest convenience store operator.

It will be an all stock transaction valuing the company at about ¥171 billion.

FamilyMart will pay 0.138 of a share for each Uny share, the companies said Thursday, about 5 percent more than Uny's closing price in Tokyo the same day. FamilyMart said in March it planned to merge with Uny and then announced terms on Oct. 15.