MATL, score 4
&=Rz
###Explanation
Explanation
Consider input 'ABBA' as an example.
&= % Implicit input. Matrix of all equality comparisons
% STACK: [1 0 0 1;
0 1 1 0;
0 1 1 0;
1 0 0 1]
R % Upper triangular part
% STACK: [1 0 0 1;
0 1 1 0;
0 0 1 0;
0 0 0 1]
z % Number of nonzeros. Implicitly display
% STACK: 6