INPUT c$
DIM a$(100)
c$ = " " + c$
FOR i = 1 TO LEN(c$) - 1
IF MID$(c$, i, 1) = " " THEN k = k + 1 ELSE a$(k) = a$(k) + MID$(c$, i, 1)
NEXT
a$(k + 1) = ""
FOR i = 1 TO k
FOR j = 2 TO k
IF a$(j) < a$(j - 1) THEN SWAP a$(j), a$(j - 1)
NEXT
NEXT
FOR i = 2 TO k
IF a$(i) = a$(i - 1) AND a$(i) <> a$(i + 1) THEN m = m + 1
NEXT
PRINT m
Тестирование выполнено в программе QB64 ( Скачать )