scoreboard players set min times_appeared 0

execute if score #abcde_sword shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = abcde_sword times_appeared
execute if score #abcde_sword shop matches 1 if score abcde_sword times_appeared < min times_appeared run scoreboard players operation min times_appeared = abcde_sword times_appeared

execute if score #trident shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = trident times_appeared
execute if score #trident shop matches 1 if score trident times_appeared < min times_appeared run scoreboard players operation min times_appeared = trident times_appeared

execute if score #paladin_sword shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = paladin_sword times_appeared
execute if score #paladin_sword shop matches 1 if score paladin_sword times_appeared < min times_appeared run scoreboard players operation min times_appeared = paladin_sword times_appeared

execute if score #sword_of_fathoms shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = sword_of_fathoms times_appeared
execute if score #sword_of_fathoms shop matches 1 if score sword_of_fathoms times_appeared < min times_appeared run scoreboard players operation min times_appeared = sword_of_fathoms times_appeared

execute if score #soul_sword_i shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = soul_sword_i times_appeared
execute if score #soul_sword_i shop matches 1 if score soul_sword_i times_appeared < min times_appeared run scoreboard players operation min times_appeared = soul_sword_i times_appeared

execute if score #unstable_sword shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = unstable_sword times_appeared
execute if score #unstable_sword shop matches 1 if score unstable_sword times_appeared < min times_appeared run scoreboard players operation min times_appeared = unstable_sword times_appeared
execute if score min times_appeared matches -1 run scoreboard players set min times_appeared 0