Vyxal, 7 bytes
KƛṫOnt+
K # Prefixes
ƛ # Map...
O # Count occurences of..
ṫ # Last item
O # In...
ṫ # All but last item
nt+ # Added to number
KƛṫOnt+
K # Prefixes
ƛ # Map...
O # Count occurences of..
ṫ # Last item
O # In...
ṫ # All but last item
nt+ # Added to number