execute at @s store result score #Emerald nl.Count run data get block ~ ~ ~ Items.[11].Count
execute at @s if score #Emerald nl.Count matches ..1 run replaceitem block ~ ~ ~ container.11 air
execute at @s if score #Emerald nl.Count matches 2.. run scoreboard players remove #Emerald nl.Count 1 
execute at @s store result block ~ ~ ~ Items.[11].Count double 1 run scoreboard players get #Emerald nl.Count 