Here is one way of handling this

Unique Item formula
x = Words( :Input, "," );
For Each( {element, index}, x, x[index] = Trim( element ) );
x = Associative Array( x ) << get keys;
x = Concat Items( x, "," );
Total Recurrence formula
x = Words( :Input, "," );
For Each( {element, index}, x, x[index] = Trim( element ) );
theList = Associative Array( x ) << get keys;
value = "";
For Each( {element}, theList, value = value || "," || Char( N Rows( Loc( x, element ) ) ) );
Substr( value, 2 );
Jim