How the /clear Command Works
The syntax is /clear <target> [item] [maxCount]. With no item it wipes the whole inventory. With an item but no amount it removes all of that item. Amount 0 is special: it removes nothing and instead reports how many of the item the player has — the standard way to check inventories.
Examples
Remove every diamond from the nearest player.
Count the nearest player's diamonds without removing them.
Remove up to 5 TNT from every red-team player.