n = int(input()) S = [input() for i in range(n)] dic = {} for s in S: dic[s] = dic.get(s,0)+1 for s in S: ans = 0 ns = list(s) for i in range(len(s)): b = ns[i] for j in range(26): c = chr(ord("a")+j) if b == c: continue ns[i] = c ans += dic.get("".join(ns),0) ns[i] = b print(ans)