n=int(input())
S=dict()      
count = 0   
for i in range(n):
    temp = raw_input()
    rev = temp[::-1]
    if(rev in S):
        count += S[rev]
        
    if(temp in S):
        S[temp] += 1
    else:
        S[temp] = 1     
    
print count