scoreboard objectives add count_item dummy
scoreboard objectives add count_item1 dummy
tag @s remove count_return

scoreboard players set @s count_item 0
scoreboard players set @s count_item1 0
execute store result score @s count_item run data get entity @s Inventory[{Slot:0b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:1b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:2b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:3b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:4b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:5b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:6b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:7b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:8b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:9b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:10b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:11b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:12b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:13b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:14b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:15b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:16b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:17b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:18b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:19b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:20b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:21b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:22b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:23b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:24b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:25b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:26b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:27b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:28b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:29b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:30b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:31b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:32b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:33b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:34b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:35b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item
execute store result score @s count_item run data get entity @s Inventory[{Slot:-106b,id:"minecraft:carrot_on_a_stick"}].count
scoreboard players operation @s count_item1 += @s count_item

clear @s[scores={count_item1=3..}] minecraft:carrot_on_a_stick