import sys

n = input()
d = {}
for i in range(0,n):
    s = raw_input()
    if(d.has_key(s)):
        d[s] += 1
    else:
        d[s] = 1
ans = 0
temp = 0
n = len(d)

for s in d.iterkeys():
    x = d[s];
    p = s[::-1]
    if(p==s):
        x *= (x-1)
        x /= 2
        temp += x
    else:
        if(d.has_key(p)):
            x *= d[p]
        else:
            x = 0
        ans += x
print (ans/2) + temp