how to remove 1 item from the players mainhand slot

i basically just want to remove the item the player is holding on it's mainhand but if it's a stack i want to remove just one item and not the entire stack
Continue to help post